Reputation:
I'm a bit confused by a few tutorials that I read about the ListView.
I have a ListView control and on the left hand side should be a name, and to the right of that name should be like another column with some more text in it. For example:
jason blah blah blah
item2 more blahs
item3 jupiter
item4 uranus
How can this be done? Is there a simple way of doing this?
Thank you
Upvotes: 1
Views: 344
Reputation: 34592
Use the Columns header collection to add the columns such as
then use the ListViewItem's collection to set the values of the columns such this
ListViewItem lvi = new ListViewItem("foo"); lvi.Add("bar"); lvi.Add("baz"); listview.Items.Add(lvi);
Now, you will have "foo", "bar" and "baz" respectively under the columns "Column #1", "Column #2" and "Column #3" respectively.
You will find the Column collection from within the Properties tool box for the listview. Be sure you set the view type to 'Details' to see this effect.
Upvotes: 1