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. Obtain the checkedlistbox value

Obtain the checkedlistbox value

Scheduled Pinned Locked Moved Visual Basic
question
5 Posts 2 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.
  • P Offline
    P Offline
    Paul McGann
    wrote on last edited by
    #1

    I have the following code to populate a checkedlistbox 'Sets up dataset Dim ds2 As New DataSet ds2 = Populate_Employees() 'Sets the checkedlistbox to the dataset and sets the displaymember and valuemember clb_employee.DataSource = ds2.Tables("Employees") clb_employee.DisplayMember = "Username" clb_employee.ValueMember = "Employee_ID" Now all i want to do is iterrate throught the checkedlist box and return the value of those that are checked. Can anyone shed some light upon this for me?

    R 1 Reply Last reply
    0
    • P Paul McGann

      I have the following code to populate a checkedlistbox 'Sets up dataset Dim ds2 As New DataSet ds2 = Populate_Employees() 'Sets the checkedlistbox to the dataset and sets the displaymember and valuemember clb_employee.DataSource = ds2.Tables("Employees") clb_employee.DisplayMember = "Username" clb_employee.ValueMember = "Employee_ID" Now all i want to do is iterrate throught the checkedlist box and return the value of those that are checked. Can anyone shed some light upon this for me?

      R Offline
      R Offline
      RyanMorris
      wrote on last edited by
      #2

      Hi Mc--Gann, The code bellow should help:

      'loop through check box list
      For i=0 To clb_employee.Items.Count - 1

      If clb_employee.Items(i).Selected Then
      'Do something with the selected value
      strValue = clb_employee.Items(i).Value.ToString

      End If

      Next

      I hope this helps.

      P 2 Replies Last reply
      0
      • R RyanMorris

        Hi Mc--Gann, The code bellow should help:

        'loop through check box list
        For i=0 To clb_employee.Items.Count - 1

        If clb_employee.Items(i).Selected Then
        'Do something with the selected value
        strValue = clb_employee.Items(i).Value.ToString

        End If

        Next

        I hope this helps.

        P Offline
        P Offline
        Paul McGann
        wrote on last edited by
        #3

        thanks man i'll give it a try let you know how i get on

        1 Reply Last reply
        0
        • R RyanMorris

          Hi Mc--Gann, The code bellow should help:

          'loop through check box list
          For i=0 To clb_employee.Items.Count - 1

          If clb_employee.Items(i).Selected Then
          'Do something with the selected value
          strValue = clb_employee.Items(i).Value.ToString

          End If

          Next

          I hope this helps.

          P Offline
          P Offline
          Paul McGann
          wrote on last edited by
          #4

          Getting this error: Public member 'selected' on type 'DataRowView' not found. *Remember this is a windows application i know this would have worked in asp Thanks

          R 1 Reply Last reply
          0
          • P Paul McGann

            Getting this error: Public member 'selected' on type 'DataRowView' not found. *Remember this is a windows application i know this would have worked in asp Thanks

            R Offline
            R Offline
            RyanMorris
            wrote on last edited by
            #5

            Sorry, my mistake, I didn't realise it was a windows application. How about trying this:

            Dim obj As Object
            For Each obj In clb_employee.CheckedItems
            strValue = obj.ToString
            Next obj

            Hopefully this will work better for you.

            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