标签:ar for sp on ad bs line new text
1.初始化控件
listView1.Items.Clear();
listView1.Columns.Clear();
ColumnHeader ch = new ColumnHeader();
ch.Width = 100;
ch.Text = "终端";
listView1.Columns.Add(ch);
ColumnHeader ch2 = new ColumnHeader();
ch2.Width = 100;
ch2.Text = "开关状态";
listView1.Columns.Add(ch2);
listView1.View = View.Details;
listView1.GridLines = true;
listView1.FullRowSelect = true;
string[] strs = txtConCode.Text.Split(‘,‘);
for (int i = 0; i < strs.Length; i++)
{
ListViewItem lvi = new ListViewItem();
lvi.Text = strs[i];
lvi.SubItems.Add("合闸");
listView1.Items.Add(lvi);
}
2.点击checkbox值,修改对应的值
private void listView1_ItemChecked(object sender, ItemCheckedEventArgs e)
{
for (int i = 0; i < listView1.Items.Count; i++)
{
if (listView1.Items[i].Checked == true)
{
listView1.Items[i].SubItems[1].Text = "分闸";
}
else
{
listView1.Items[i].SubItems[1].Text = "合闸";
}
}
}
标签:ar for sp on ad bs line new text
原文地址:http://www.cnblogs.com/Anders888/p/4030956.html