CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2009
    Posts
    3

    Listview.SubItems not exist?

    I was attempting to follow a few tutorials for the ListView control. I am able in the designer to add items and subitems but I want to be able to add them in at runtime. I can do ListView1.Items.Add quite fine but when I attemp to input ListView1.SubItems (As the tutorial suggests) I get an error that is:
    Code:
    'SubItems' is not a member of 'System.Windows.Forms.ListView'
    I am using Visual Basic.NET 2008 Express.

  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: Listview.SubItems not exist?

    Subitmes are Items of an Item. ListView1 in your case does not contain subitems. ListView1.Items(0) however would contain SubItems.

    I like to add items by using a listview item. This to me makes the code much more readable.

    Code:
            Dim LSingleItem As ListViewItem
            LV.Clear()
            LV.View = View.Details
            LV.GridLines = True
            LSingleItem = LV.Items.Add("Text")
            LSingleItem.SubItems.Add("SubItem Text")
    
    or.....
    
            LSingleItem = LV.Items(1)
            LSingleItem.SubItems.Add("SubItem Text")
    Where LV is my listview.

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