开发者

How to edit a selected SubItem programmatically?

开发者 https://www.devze.com 2022-12-25 21:29 出处:网络
Does anyone know how can I edit a subitem on a listView? I\'开发者_Python百科ve tried using this:

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

精彩评论

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