Results 1 to 7 of 7

Thread: ListView subitems...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    Palermo, Italy
    Posts
    325

    ListView subitems...

    There's a property that lets to modify items' labels in place, but how to modify subitems' labels?

    Thanks
    Learn, this is the Keyword...

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    ListViewItem.Subitems(X).Text

    where X is the subitem index e.g. for column 4, it would be subitem(3).

    ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemWindowsFormsListViewItemClassSubItemsTopic.htm
    Last edited by Slow_Learner; May 3rd, 2003 at 09:29 AM.

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    Re: ListView subitems...

    Originally posted by Xmas79
    There's a property that lets to modify items' labels in place, but how to modify subitems' labels?

    Thanks
    Unless you are talking about the manual edit of a listitem's text, in which case I think that is possible on only the first subitem. Subitem(0) I guess.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    Palermo, Italy
    Posts
    325
    Uhm.. Then I think I have to move to some other control...
    Thx..
    Learn, this is the Keyword...

  5. #5
    Fanatic Member
    Join Date
    May 2001
    Posts
    525

    Re: ListView subitems...

    Has anyone figured out a way to edit other subitems besides 0?

  6. #6
    Junior Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    21

    Re: ListView subitems...

    assuming u got a blank list view called lvTest

    so u try this out

    VB Code:
    1. lvTest.Items.Add("column1 thingie")  
    2. lvTest.Items(0).SubItems.Add("column2 thingie")  
    3. lvTest.Items(0).SubItems.Add("column3 thingie")

  7. #7
    Lively Member jberman's Avatar
    Join Date
    Nov 2004
    Location
    Hollywood, FL
    Posts
    103

    Re: ListView subitems...

    As a general practise you may want to do place something like this at the top of the form containing the ListView to represent the columns, or subitems, that your ListView contains:

    VB Code:
    1. Const Grid_ID As Integer = 0
    2.     Const Grid_Name As Integer = 1
    3.     Const Grid_Address As Integer = 2
    4.     Const Grid_State As Integer = 3
    5.     Const Grid_City As Integer = 4

    By doing so you can access the subitems in the following way, for say, editing:

    VB Code:
    1. MyListView.Items(MyIndex).SubItems(Grid_Name).Text = MyNewName

    Plus if you ever reorder the columns you can just change the values for the consts that you declared at the top of your form and they will continue to access the correct subitem. Hope that helped!

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