开发者

How to edit a selected SubItem programmatically?

Does anyone know how can I edit a subitem on a listView? I'开发者_Python百科ve tried using this:

ListView1.SelectedItems[0].SubItems[1].Text = "Hello?";

But that doesn't work. I get the error "InvalidArgument=Value of '1' is not valid for 'index'". I've got two columns on the listview, so I figured the index of [1] would be the subitem.


Have you actually added an item with a subitem to the list? Just because you have two columns the ListViewItem doesn't automatically get 2 subitems.

For example if you have done the following:

ListViewItem item = listView1.Items.Add("test");  
item.SubItems.Add("sub1");

Then it should work, but if you only have:

ListViewItem item = listView1.Items.Add("test");

Then it won't.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜