tehon3299 Posted March 27, 2003 Posted March 27, 2003 I have a listview with 2 columns and I need to know how to put things in the second column. When I do a: 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?? Quote Thanks, Tehon
Moderators Robby Posted March 27, 2003 Moderators Posted March 27, 2003 Have a look at SubItems of the ListViewItems... Here's a sample project (checkout Form2)listview statusbar.zip Quote Visit...Bassic Software
philprice Posted March 27, 2003 Posted March 27, 2003 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. Quote Phil Price� Visual Studio .NET 2003 Enterprise Edition Microsoft Student Partner 2004 Microsoft Redmond, EMEA Intern 2004
tehon3299 Posted March 27, 2003 Author Posted March 27, 2003 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? Quote Thanks, Tehon
Moderators Robby Posted March 27, 2003 Moderators Posted March 27, 2003 The "1" can be an everchanging field value from the table (dataReader) item1.SubItems.Add("1") [edit] In the CreateMyListView routine, there is no loop but obviously you will have a loop.... While MyReader.... [/edit] Quote Visit...Bassic Software
tehon3299 Posted March 27, 2003 Author Posted March 27, 2003 But how would I change the first column from "Item1" to whatever I am reading? Quote Thanks, Tehon
Ariez Posted March 27, 2003 Posted March 27, 2003 define a Litem as listviewitem then Litem= lvwTeams.Items.add...(whatever) Litem.subitems.add (thats your second col..) Quote Auto-suggestion: "I have a life" Uncontroled thinking: "So what the.."
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.