Obtain the checkedlistbox value
-
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?
-
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?
Hi Mc--Gann, The code bellow should help:
'loop through check box list
For i=0 To clb_employee.Items.Count - 1If clb_employee.Items(i).Selected Then
'Do something with the selected value
strValue = clb_employee.Items(i).Value.ToStringEnd If
Next
I hope this helps.
-
Hi Mc--Gann, The code bellow should help:
'loop through check box list
For i=0 To clb_employee.Items.Count - 1If clb_employee.Items(i).Selected Then
'Do something with the selected value
strValue = clb_employee.Items(i).Value.ToStringEnd If
Next
I hope this helps.
thanks man i'll give it a try let you know how i get on
-
Hi Mc--Gann, The code bellow should help:
'loop through check box list
For i=0 To clb_employee.Items.Count - 1If clb_employee.Items(i).Selected Then
'Do something with the selected value
strValue = clb_employee.Items(i).Value.ToStringEnd If
Next
I hope this helps.
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
-
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
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 objHopefully this will work better for you.