Results 1 to 6 of 6

Thread: listview checkboxes not working

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    193

    listview checkboxes not working

    I have a listview with checkboxes, when I loop thru it, it always says that all of the items are checked, but they aren't, I step thru it to verify.


    For Each lstItem In lsvStations.Items
    If lstItem.Checked Then
    QString = QString & lstItem.Text & ","
    End If
    Next lstItem

    WHat is wrong,,
    THanks for help

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    193

    Re: listview checkboxes not working

    One more thing, in case it matters, this is in VB.NET

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: listview checkboxes not working

    Quote Originally Posted by DebbieInFlorida
    One more thing, in case it matters, this is in VB.NET
    It does.

    Moved.

    It also matters what version of VB.NET. Are you using 2005?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    193

    Re: listview checkboxes not working

    thanks for moving me, old habits are hard to break.. I am using VS 2005

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: listview checkboxes not working

    in .NET you can access a collection of ONLY the checked listviewitems from the listview...

    vb Code:
    1. 'LOOP CHECKED ITEMS
    2.         For Each lstItem In lsvStations.CheckedItems
    3.             'ADD ITEM TEXT TO STRING
    4.             QString &= lstItem.Text & ","
    5.         Next
    6.         'TRIM TRAILING "," FROM END OF QString
    7.         QString = QString.TrimEnd(","c)

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    193

    Re: listview checkboxes not working

    Thanks Klein,
    That looks so obvious. I didn't realize there were so many changes with .NET, have only been in it for a month, but I really like it.
    Cheers

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