Click to See Complete Forum and Search --> : [RESOLVED] Adding items to a detailed ListView
Kasracer
Jan 29th, 2006, 02:09 PM
I have a ListView that is in detailed view and it has 3 columns (col1, col2, and col3).
How do I add an item to each column?
Mike Hildner
Jan 29th, 2006, 02:35 PM
You still just add a ListViewItem, but the ListViewItem has SubItems. In this code I create an item with an image index of 0 and then add a sub item to it. The sub item shows up in the second column.
private void DisplayLoadedAssemblies()
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly a in assemblies)
{
AssemblyName an = a.GetName();
ListViewItem item = new ListViewItem(an.Name.ToString(), 0);
item.SubItems.Add(an.Version.ToString());
this.lvAssemblies.Items.Add(item);
Debug.WriteLine(a.ToString());
}
}
Mike
Kasracer
Jan 29th, 2006, 06:09 PM
Thanks. I knew I had to do something with the SubItem.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.