Results 1 to 6 of 6

Thread: [RESOLVED] Displaying Items In A Checked ListView

  1. #1

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

    Resolved [RESOLVED] Displaying Items In A Checked ListView

    I have a ListView control with checkboxes. I want to add all checked items into a textbox. In order to find out what items are checked, I'm doing this in a loop
    VB Code:
    1. Dim i As Long
    2. For i = 1 To ListView1.ListItems.Count
    3.       If ListView1.ListItems.Items(i).Checked = True Then
    4.          'add to textbox
    5.      End If
    6. Next
    But I get a "Method or Data member not found" and it hightlights ".Items(i)

    How do I pick up all checked items in a ListView?
    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
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Displaying Items In A Checked ListView

    If ListView1.ListItems(x).Checked = True Then
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

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

    Re: Displaying Items In A Checked ListView

    Thanks Static. That doesn't blow up, but I'm getting all the same line.

    Example: Say I have this in my ListView

    Apples
    Pears
    Peachs
    Oranges
    Apricots

    And, I check Pears and Oranges

    My textbox should have:

    Pears
    Oranges

    in it, but what it has is:

    Apples
    Apples

    If I check three things, the the very first listitem is appearing three times.

    How do I get what I have checked to be in the textbox?
    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.

  4. #4

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

    Re: [RESOLVED] Displaying Items In A Checked ListView

    I got it.
    VB Code:
    1. Dim i As Long
    2. Text1.Text = vbNullString
    3. For i = 1 To ListView1.ListItems.Count
    4.     If ListView1.ListItems.Item(i).Checked = True Then
    5.        Text1.Text = Text1.Text & ListView1.ListItems(i).Text & vbNewLine
    6.     End If
    7. Next
    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
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: [RESOLVED] Displaying Items In A Checked ListView

    odd. this is what i used and it worked fine...
    VB Code:
    1. For x = 1 To ListView1.ListItems.Count
    2.         If ListView1.ListItems(x).Checked = True Then
    3.             Debug.Print ListView1.ListItems(x).Text
    4.         End If
    5.     Next
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  6. #6
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: [RESOLVED] Displaying Items In A Checked ListView

    ok.. cool
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

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