Click here to Skip to main content
13,295,429 members (52,920 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi I have created a listview through xaml file and have added items to it. How to add subitems to that list view? I am not getting subitems property. Pls help me

This is my code for Listview creation.

<ListView Height="228" HorizontalAlignment="Left" Margin="284,79,0,0" Name="lsvAnalysts" VerticalAlignment="Top" Width="381" SelectionChanged="lsvAnalysts_SelectionChanged"/>

This is my code for adding items to it

Posted 7-Nov-12 23:48pm
Updated 8-Nov-12 1:16am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The MSDN links you'll want to read are[^]and[^].
You access the subitems of your list view item through the ListViewItem.SubItems property Most important thing to remember is that the first sub-item refers to the owner list view item so to access the actual sub-items you need to index starting at 1. This will return you a ListViewSubItem object and you can get it's text string by calling ListViewSubItem.Text.
Member 9562996 8-Nov-12 5:31am
No I am not getting subitem property? This is my code
ListViewItem i = new ListViewItem();
i.Content = "one";
Member 9562996 8-Nov-12 6:16am
Pls check my updated question
mehdi.sabet 8-Nov-12 6:42am
can you add this two item in listliew by this code?
Member 9562996 8-Nov-12 6:52am
yes it is added and i got the value through selecteditem
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

ListViewItem item = new ListViewItem();
item.Subitems.Add or if it is a collection you can get Item[index].Subitems.add
Member 9562996 8-Nov-12 6:54am
No i am not getting Subitems property iteself even i added items as you said above

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171207.1 | Last Updated 8 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100