Listview

tehon3299

Centurion
Joined
Jan 6, 2003
Messages
155
Location
Liverpool, NY
I have a listview with 2 columns and I need to know how to put things in the second column. When I do a:
Visual Basic:
lvwTeams.Items.Add(myReader.GetValue(6) & " (" & myReader.GetValue(2) & myReader.GetValue(3) & ")")
it only puts thing in the first column. How do I do this??
 
in vb6, (im sure its the same now) the add method would return a listItem (not sure what its called now), then you could do listItem.SubItems(X) and set the other columns. Same way with a tree view and tree nodes in .NET (only similar control ive used in .net) - im sure there will be additional .Add signitures so you can add listItems staight off.
 
OK...Now I don't know how many rows I will have since I am getting this from an SQL table. So how would I create these "items1, items2..." on the fly?
 
The "1" can be an everchanging field value from the table (dataReader)
Visual Basic:
 item1.SubItems.Add("1")
[edit]
In the CreateMyListView routine, there is no loop but obviously you will have a loop.... While MyReader....
[/edit]
 
define a Litem as listviewitem

then

Litem= lvwTeams.Items.add...(whatever)
Litem.subitems.add (thats your second col..)
 
Back
Top