|
使用listview一定要使用模板吗?试着用winfom中listview的使用方式发现无相应的类接口函数,如下面的view,LableEdit,Items等属性都标记了下划线
this.listView1.GridLines = true; //显示表格线
this.listView1.View = View.Details;//显示表格细节
this.listView1.LabelEdit = true; //是否可编辑,ListView只可编辑第一列。
this.listView1.Scrollable = true;//有滚动条
this.listView1.HeaderStyle = ColumnHeaderStyle.Clickable;//对表头进行设置
this.listView1.FullRowSelect = true;//是否可以选择行
//this.listView1.HotTracking = true;// 当选择此属性时则HoverSelection自动为true和Activation属性为oneClick
//this.listView1.HoverSelection = true;
//this.listView1.Activation = ItemActivation.Standard; //
//添加表头
this.listView1.Columns.Add("列0", 50);
this.listView1.Columns.Add("列1", 80);
this.listView1.Columns.Add("列2", 160);
//添加各项
ListViewItem[] p = new ListViewItem[4];
p[0] = new ListViewItem(new string[] { "1", "aaaa", "bbbb" });
p[1] = new ListViewItem(new string[] { "2", "bbbb", "ggggg" });
p[2] = new ListViewItem(new string[] { "3", "cccc", "dafdf" });
p[3] = new ListViewItem(new string[] { "4", "dddd", "32532" });
//p[0].SubItems[0].BackColor = Color.Red; //用于设置某行的背景颜色
this.listView1.Items.AddRange(p);
|
|