简单的ListView应用

本文介绍了一个简单的ListView应用案例,展示了如何使用C#设置ListView的视图样式、分组及添加项目。通过具体代码实现了列表视图中不同分组的数据展示。

ListView  Designer代码:


     
//
// listView1
//
this .listView1.Columns.AddRange( new System.Windows.Forms.ColumnHeader[] {
this .name,
this .caption});
this .listView1.Dock = System.Windows.Forms.DockStyle.Fill;
listViewGroup1.Header
= " 系统基本信息 " ;
listViewGroup1.Name
= " 系统基本信息 " ;
listViewGroup2.Header
= " 设备信息 " ;
listViewGroup2.Name
= " 设备信息 " ;
this .listView1.Groups.AddRange( new System.Windows.Forms.ListViewGroup[] {
listViewGroup1,
listViewGroup2});
this .listView1.Location = new System.Drawing.Point( 0 , 0 );
this .listView1.Name = " listView1 " ;
this .listView1.Size = new System.Drawing.Size( 474 , 262 );
this .listView1.TabIndex = 0 ;
this .listView1.UseCompatibleStateImageBehavior = false ;
this .listView1.View = System.Windows.Forms.View.Details;
//

前台代码:

 


     
string [] stra = { " 计算机系统 " , " WIN7 旗舰版 " };
this .listView1.Items.Add( new ListViewItem(stra, 1 , this .listView1.Groups[ 0 ]));
this .listView1.Items.Add( new ListViewItem( new string []{ " 1 " , " 2 " }, 0 , this .listView1.Groups[ 1 ]));

 

 效果图:

 

 

 

posted on 2010-11-15 17:46 夏天哥哥 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/xiatianhe/archive/2010/11/15/1877864.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值