There's a property that lets to modify items' labels in place, but how to modify subitems' labels?
Thanks
Printable View
There's a property that lets to modify items' labels in place, but how to modify subitems' labels?
Thanks
ListViewItem.Subitems(X).Text
where X is the subitem index e.g. for column 4, it would be subitem(3).
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemWindowsFormsListViewItemClassSubItemsTopic.htm
Unless you are talking about the manual edit of a listitem's text, in which case I think that is possible on only the first subitem. Subitem(0) I guess.Quote:
Originally posted by Xmas79
There's a property that lets to modify items' labels in place, but how to modify subitems' labels?
Thanks
Uhm.. Then I think I have to move to some other control...
Thx..
Has anyone figured out a way to edit other subitems besides 0?
assuming u got a blank list view called lvTest
so u try this out
VB Code:
lvTest.Items.Add("column1 thingie") lvTest.Items(0).SubItems.Add("column2 thingie") lvTest.Items(0).SubItems.Add("column3 thingie")
As a general practise you may want to do place something like this at the top of the form containing the ListView to represent the columns, or subitems, that your ListView contains:
VB Code:
Const Grid_ID As Integer = 0 Const Grid_Name As Integer = 1 Const Grid_Address As Integer = 2 Const Grid_State As Integer = 3 Const Grid_City As Integer = 4
By doing so you can access the subitems in the following way, for say, editing:
VB Code:
MyListView.Items(MyIndex).SubItems(Grid_Name).Text = MyNewName
Plus if you ever reorder the columns you can just change the values for the consts that you declared at the top of your form and they will continue to access the correct subitem. Hope that helped!