CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Listview

  1. #1
    Join Date
    Apr 2004
    Posts
    265

    Listview

    Hi,

    How do I add a subitem to a listview in WPF? I do not see any subitem in it.

    Thanks

  2. #2
    Join Date
    Jan 2009
    Posts
    36

    Re: Listview

    Look into using the ItemTemplate for the ListView. This defines what controls will be rendered for each item. Check out MSDN for more details. If your new to WPF and templating in general, definitely search around and read up on those topics.

  3. #3
    Join Date
    Apr 2004
    Posts
    265

    Re: Listview

    My ListView control is not bound. I did code this way.

    Code:
            Dim lvi As New System.Windows.Forms.ListViewItem
            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?

  4. #4
    Join Date
    Jan 2009
    Posts
    36

    Re: Listview

    I don't think I am following you very well. I assumed from your original post that you were trying to take some existing Windows Forms code and port it over to WPF. Are we both talking WPF here or did you mean Windows Forms all along? Your right in that the WPF ListViewItem does not have SubItems like Forms do.

    Do you have any WPF code written yet that you could share as a starting point?

  5. #5
    Join Date
    Apr 2004
    Posts
    265

    Re: Listview

    Thanks for your reply. I managed to solve it.

    I created a Datatable and filled rows of the table like this

    Code:
    tbl.Rows.Add(blk.Name, dwgFile)
    Then I assigned the datatable to the listview and the problem is solved.

    Thanks

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

Featured