怎样使用C#的listview控件
展开全部
this.listView1.View = View.Details; //显示的样式
ListView listView1 = new ListView();
listView1.GridLines = true;//显示行线
listView1.Sorting = SortOrder.Ascending;//升序还是降序
this.listView1.Columns.Add("编号", 60, HorizontalAlignment.Right);
this.listView1.Columns.Add("姓名", 60, HorizontalAlignment.Right);
this.listView1.Columns.Add("年龄", 60, HorizontalAlignment.Right);
this.listView1.Columns.Add("电话", 60, HorizontalAlignment.Right);
this.listView1.Visible = true;
foreach (T t in list<T>)//这里就循环你的数据源数据就行
{
ListViewItem li = new ListViewItem();
li.SubItems[0].Text = t.ToString();
li.SubItems.Add(t.aa);
li.SubItems.Add(t.bb);
li.SubItems.Add(t.cc);
this.listView1.Items.Add(li);
}
ListView listView1 = new ListView();
listView1.GridLines = true;//显示行线
listView1.Sorting = SortOrder.Ascending;//升序还是降序
this.listView1.Columns.Add("编号", 60, HorizontalAlignment.Right);
this.listView1.Columns.Add("姓名", 60, HorizontalAlignment.Right);
this.listView1.Columns.Add("年龄", 60, HorizontalAlignment.Right);
this.listView1.Columns.Add("电话", 60, HorizontalAlignment.Right);
this.listView1.Visible = true;
foreach (T t in list<T>)//这里就循环你的数据源数据就行
{
ListViewItem li = new ListViewItem();
li.SubItems[0].Text = t.ToString();
li.SubItems.Add(t.aa);
li.SubItems.Add(t.bb);
li.SubItems.Add(t.cc);
this.listView1.Items.Add(li);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询