|
-
October 26th, 2011, 12:20 PM
#1
Display List items in ListView
I'm having major brain-fart.
On my form I have a List of a custom class. It's a very simple class that just holds values for multiple properties. All I want to do is display the value of 2 of these properties for each class in a ListView. I can easily do it in a single column, like this:
Code:
private void UpdateCreatureList()
{
lvwCreatures.Items.Clear();
foreach (Creature item in Creatures)
{
lvwCreatures.Items.Add(item.CreatureName + ": " + item.Miniature);
}
}
Creatures is the List<Creature> object.
What I want to do is change the ListView so it has 2 columns: Creature & Miniature. Then I want to populate each column with its respective property value from the List.
Code:
if (Issue.Resolved)
{
ThreadTools.Click();
MarkThreadResolved();
}
-
October 26th, 2011, 04:50 PM
#2
Re: Display List items in ListView
I don't see anything wrong with what your doing there....
-
October 27th, 2011, 01:34 AM
#3
Re: Display List items in ListView
Are you setting your list view to the correct style, i.e. Detail or is it Report? Haven't worked much with Listview in .Net but should be something like that, additional columns are subitems of the item in question.
Always use [code][/code] tags when posting code.
-
October 27th, 2011, 03:50 AM
#4
Re: Display List items in ListView
Details would be the best View here, then you could do something like :
Code:
private void UpdateCreatureList()
{
lvwCreatures.Items.Clear();
foreach (Creature item in Creatures)
{
ListViewItem lvItem1 = new ListViewItem(item.CreatureName,0);
lvItem1.SubItems.Add(item.Miniature);
}
}
-
October 27th, 2011, 09:37 AM
#5
Re: Display List items in ListView
I wasn't in Details view and I added in the SubItems- that got everything working.
Thanks,
Code:
if (Issue.Resolved)
{
ThreadTools.Click();
MarkThreadResolved();
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|