Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. listview control problem

listview control problem

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    monafr81
    wrote on last edited by
    #1

    Hi every body , i have a problem ?? i have a list view control in windows application , and i set its chcek property to true i want if the user Check an item to make all other items unchecek and i don't know how :confused: ? i try too much but it doesnot work Can You help me how to do it ?? Thanks Mona .

    LA ELAH ELA ALLAH MOHAMED RASOL ALLAH

    D 1 Reply Last reply
    0
    • M monafr81

      Hi every body , i have a problem ?? i have a list view control in windows application , and i set its chcek property to true i want if the user Check an item to make all other items unchecek and i don't know how :confused: ? i try too much but it doesnot work Can You help me how to do it ?? Thanks Mona .

      LA ELAH ELA ALLAH MOHAMED RASOL ALLAH

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You'd have to handle the ItemChecked event of the ListView, which will give you the item that was clicked on. You'd then have to set a static flag in the event handler that will signal that you are changing check marks. Iterate over the items in the list, changing each check mark, then reset the flag. Since changing the check mark will fire the same event again, the handler code has to start by check that flag. If it's set, then the handler code can exit without making any changes. But, wouldn't this be a job for RadioButtons?? After all, this is exactly what they do.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      M 1 Reply Last reply
      0
      • D Dave Kreskowiak

        You'd have to handle the ItemChecked event of the ListView, which will give you the item that was clicked on. You'd then have to set a static flag in the event handler that will signal that you are changing check marks. Iterate over the items in the list, changing each check mark, then reset the flag. Since changing the check mark will fire the same event again, the handler code has to start by check that flag. If it's set, then the handler code can exit without making any changes. But, wouldn't this be a job for RadioButtons?? After all, this is exactly what they do.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        M Offline
        M Offline
        monafr81
        wrote on last edited by
        #3

        thanks for your replay but can you mak it more simple , sorry i am new in vb so can u explain with code , it'll be better and easy to understand Thanks a lot Mona :|

        LA ELAH ELA ALLAH MOHAMED RASOL ALLAH

        C M 2 Replies Last reply
        0
        • M monafr81

          thanks for your replay but can you mak it more simple , sorry i am new in vb so can u explain with code , it'll be better and easy to understand Thanks a lot Mona :|

          LA ELAH ELA ALLAH MOHAMED RASOL ALLAH

          C Offline
          C Offline
          C1AllenS
          wrote on last edited by
          #4

          Hello, Please try this code. I believe this should assist you. Private Sub ListView1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles ListView1.ItemCheck For i As Integer = 0 To Me.ListView1.Items.Count - 1 If i <> e.Index Then Me.ListView1.Items(i).Checked = False End If Next End Sub Regards, Allen

          Allen Smith Software Engineer ComponentOne LLC www.componentone.com

          1 Reply Last reply
          0
          • M monafr81

            thanks for your replay but can you mak it more simple , sorry i am new in vb so can u explain with code , it'll be better and easy to understand Thanks a lot Mona :|

            LA ELAH ELA ALLAH MOHAMED RASOL ALLAH

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            or another one If Bloading the exit sub bLoading = true For each oItem as Listview item in LVData.items oitem.checked = true next

            Never underestimate the power of human stupidity RAH

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups