How to add subitems to a ListView?

前端 未结 3 1085
时光说笑
时光说笑 2021-01-05 17:57

I\'m trying to get the simplest possible example of a Listview with subitems working. But this code:

private void button1_Click(object sender, EventArgs e) {         


        
3条回答
  •  遥遥无期
    2021-01-05 18:31

    Try adding the item after adding a subitem:

    ListViewItem lvi = new ListViewItem(strArr[i]);
    lvi.SubItems.Add("Ciao, Baby!");
    listView1.Items.Add(lvi);    
    listView1.Items[i].Group = listView1.Groups[0];
    

    Hope this helps!

提交回复
热议问题