c# listView1.连续加行
2021-04-06 21:27
标签:标题 返回 checked 头信息 list view items c# text c# listView1.连续加行 标签:标题 返回 checked 头信息 list view items c# text 原文地址:https://www.cnblogs.com/thisdo/p/9125102.html //自定义加列
listView1.Columns.Clear();//全部删除
int w = listView1.Columns.Count;//总列数
ColumnHeader q = listView1.Columns.Add(w.ToString(), "yoyo", 100);//返回列头信息
q = listView1.Columns.Add(q.Index.ToString(),"lala",100);
q = listView1.Columns.Add(q.Index.ToString(), "momo", 100);
//方法一,连续加行
int index = 0,x = 0;
for (int j = 0; j 3;j++ )
{
ListViewItem a = listView1.Items.Add(j.ToString());
index = a.Index;
for (int n = 0; n )
{
x = n + 1;
listView1.Items[index].SubItems.Add("第" + x.ToString() + "列");
}
}
//方法二,连续加行
int p = 0;
for (int k = 0; k 3;k++ )
{
//添加一整行
ListViewItem itemx = new ListViewItem("itemx" + k.ToString());//第0列标题
for (int i = 0; i 3; i++)
{
itemx.Checked = true;
p = i + 1;
itemx.SubItems.Add("第" + p.ToString() + "列"); //添加列标题,从第1列开始
}
listView1.Items.AddRange(new ListViewItem[] { itemx });
}
listView1.Items[0].Text = "00";//修改第0行第0列
listView1.Items[0].SubItems[1].Text = "ok";//修改第0行第1列
listView1.Items[1].SubItems[2].Text = "very ok";//修改第1行第2列
上一篇:windows 如何创建硬链接
下一篇:C - Twins