subitem declaration

howester77

Active member
Joined
Aug 5, 2005
Messages
38
Programming Experience
5-10
In my listview, I have 9 coloums and 9 rows, for a total of 81 (9x9) subitems. Is there any easier way to declare the subitems instead of doing it like this:

'Create SubItem 1
Dim itms1 As New Windows.Forms.ListViewItem.ListViewSubItem _
(itmp, "SubItem 1")

'Create SubItem 2
Dim itms2 As New Windows.Forms.ListViewItem.ListViewSubItem _
(itmp, "SubItem 2")

'Create SubItem 3
Dim itms3 As New Windows.Forms.ListViewItem.ListViewSubItem _
(itmp, "SubItem 3")
 
VB.NET:
Dim lvItem as ListViewItem
Dim i as integer
For i = 0 to 20
lvitem = listview1.items.add("item " & i)
lvitem.subitems.add("item " & i)
lvitem.subitems.add("item " & i)
lvitem.subitems.add("item " & i)
lvitem.subitems.add("item " & i)
.
.
.
Next

then you can refer each subitem like this:
VB.NET:
For each lvitem in ListView1.Items
lvitem.Subitems(2).Text = String.Empty 'third column will be emptied
Next

Cheers ;)
 
that just clears objects. How do you clear everything? for example, I start the program with a blank listview1 (no coloums/rows, nothing)and add things on to it. How do I get it back to the way it was when you start the program?
 
Back
Top