Results 1 to 11 of 11

Thread: [RESOLVED] [2005] Retrieving SubItems Value

  1. #1

    Thread Starter
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160

    Resolved [RESOLVED] [2005] Retrieving SubItems Value

    I have a ListView with three columns. The first two are text and third is numeric.

    I need to get the value from column three (subitem(2)). Here is what I've tried
    Code:
    Messagebox.Show(lvwAddresses.SelectedItems.Item(2)
    But, I got this error message: "Value of type 'System.Windows.Forms.ListViewItem' cannot be converted to 'String'."

    So, I tried
    Code:
    MessageBox.Show(lvwAddresses.SelectedItems.ToString(Item(2)))
    Then I got this error message: "Name item is not declared."

    So, how would I get that?
    Beantown Boy
    Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.

  2. #2
    Hyperactive Member JXDOS's Avatar
    Join Date
    Aug 2006
    Location
    Mars...
    Posts
    423

    Re: [2005] Retrieving SubItems Value

    lvwAddresses.SelectedItem.Tostring is enough

    You just have to make sure that all three lists have the same item index selected.... if that is what you want??

    lvwAddresses.SelectedItemIndex = otherlist.SelectedItemIndex etc...

    Messagebox.Show(list1.selectedIem.Tostring + list2.selectedIem.Tostring + lvwAddresses.selectedIem.Tostring)
    If my post has been helpful, please rate it!

  3. #3
    Hyperactive Member
    Join Date
    Dec 2004
    Posts
    326

    Re: [2005] Retrieving SubItems Value

    Try

    lvwAddresses.SelectedItems(2).Text

  4. #4

    Thread Starter
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160

    Re: [2005] Retrieving SubItems Value

    Quote Originally Posted by JXDOS
    You just have to make sure that all three lists have the same item index selected
    I don't know what you mean by this. I have one ListView with three columns, not three lists.
    Beantown Boy
    Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.

  5. #5

    Thread Starter
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160

    Re: [2005] Retrieving SubItems Value

    Quote Originally Posted by JXDOS
    lvwAddresses.SelectedItem.Tostring is enough
    This resulted in this
    Attached Images Attached Images  
    Beantown Boy
    Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.

  6. #6
    Hyperactive Member JXDOS's Avatar
    Join Date
    Aug 2006
    Location
    Mars...
    Posts
    423

    Re: [2005] Retrieving SubItems Value

    oops.. sorry misread
    If my post has been helpful, please rate it!

  7. #7

    Thread Starter
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160

    Re: [2005] Retrieving SubItems Value

    Quote Originally Posted by zalez
    Try

    lvwAddresses.SelectedItems(2).Text
    This resulted in this
    Attached Images Attached Images  
    Beantown Boy
    Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.

  8. #8
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [2005] Retrieving SubItems Value

    Code:
    For Each item As ListViewItem In lvwAddresses.SelectedItems
      For Each subItem As ListViewItem.ListViewSubItem In item.SubItems
        Console.Out.WriteLine(subItem.Text)
      Next
    Next

  9. #9
    Hyperactive Member
    Join Date
    Dec 2004
    Posts
    326

    Re: [2005] Retrieving SubItems Value

    lvwAddresses.SelectedItems.Item(0).SubItems(2).Text

  10. #10

    Thread Starter
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160

    Re: [2005] Retrieving SubItems Value

    Quote Originally Posted by zalez
    lvwAddresses.SelectedItems.Item(0).SubItems(2).Text
    That is what I needed.

    Thanks!
    Beantown Boy
    Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.

  11. #11
    Hyperactive Member
    Join Date
    Dec 2004
    Posts
    326

    Re: [RESOLVED] [2005] Retrieving SubItems Value

    You are welcome

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