Results 1 to 6 of 6

Thread: Listview

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Location
    India
    Posts
    318

    Listview

    Hi,

    How do I add a subitem to a listview in WPF? I'm coding in VB and I do not see any subitem in it.

    Thanks

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Listview

    If you are coding in VB, then it should work the same
    vb.net Code:
    1. Dim lvwItem As New ListViewItem()
    2.  
    3. lvwItem = ListView1.Items.Add("blah")
    4. lvwItem.SubItems.Add("More Blah")
    5. 'etc

  3. #3
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Listview

    No its not the same Hack, the ListViewSubItem class doesnt exist in WPF.
    Have a look at the link in my signature titled something like "Editable Listview in WPF" and that should give you a good idea how to do what you want.
    Post back here if you get stuck

    Also, in this WPF forum there is a thread titled "WPFisms: Tips Tricks and Changes from Winforms", which highlights this difference
    http://www.vbforums.com/showthread.php?t=555189
    Last edited by chris128; May 27th, 2009 at 07:34 AM.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Location
    India
    Posts
    318

    Re: Listview

    I did it this way.

    Code:
    For Each blk In blks
                If blk.IsXRef Then
                    Dim intIndex As Integer = Array.IndexOf(Src, blk.Name.ToString)
                    If intIndex >= 0 Then
                        lvi.Text = blk.Name
                        lvi.SubItems(0).Text = "test"
                        LV.Items.Add(lvi)
                    End If
                End If
     Next
    But the result I get in the ListView is

    ListViewItem:{test} ListViewItem:{test}

    What could be wrong?

  5. #5
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Listview

    Did you look at the thread I mentioned (in my signature) at all?

    You can bind the listview to your collection and then use the DisplayMemberBinding property of each column in the listview to select which columns show which properties from your collection
    Last edited by chris128; May 28th, 2009 at 03:39 AM.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Listview

    Quote Originally Posted by chris128 View Post
    No its not the same Hack, the ListViewSubItem class doesnt exist in WPF.
    Thanks!

    After looking around a bit, I found this. Hopefully it will be useful.

    http://www.switchonthecode.com/tutor...istview-part-1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width