我想在多个行和列中添加值,但条件是我希望在特定的行和列中添加值。
// this is my method get called with struct type List
void showbind(List<binddata> bindinfo)
{
foreach (var item in bindinfo)
{
string ip = item.serIp; // structure items
int col = item.column;
string sc = item.scipt;
string o_ut=item.output;
// here I'm getting the index of row...
int i = Array.IndexOf(Program.CheckIp.Keys.ToArray(), "ip");
// here I want to add the output value at the "col"
// number column..... "lstVwServerList" is the item id.
lstVwServerList.Columns[col].Text = o_ut;
}
}
答案 0 :(得分:0)
在此示例中,我具有3列的listView1,添加2行,并在每行中更改2个值;请为您自己定制。
private void button2_Click(object sender, EventArgs e)
{
string[] row = { "qqq", "ddd", "ccc" };
var listViewItem = new ListViewItem(row);
listView1.Items.Add(listViewItem);
listView1.Items[0].Text = "hi";
row = new string[3];
row[0] = "vvv";
row[1] = "ooo";
row[2] = "zzz";
listViewItem = new ListViewItem(row);
listView1.Items.Add(listViewItem);
listView1.Items[1].SubItems[1].Text = "hi";
}