CheckedListBox .net Read Values
Posted on 2006-05-22
Here is a brief description of what i am trying to accomplish:
I have populated a checkedlistbox with more than one options sometimes (it depends on the user's selection). I want to check one, two or all options. I have a variable in my program called "Rate". Once the user selects any option in the checkedlistbox, i want to add the value for that specific selection to the "Rate" variable.
Ex: My rate variable carries a value of 0.50. I make a selection in my checkedlistbox that has a rate of 0.25. Now i want my rate variable to become 0.75.
I have a code below that works only when i display one option in the checkedListBox. Everytime i have two or more options, it ingores the whole procedure if i only select one option and leave the other ones unchecked.
Thanks for any inputs
'---loops through all items in the checkedlistbox
For i = 0 To (chkEndorsement.Items.Count - 1)
'----checks for the checked options
If chkEndorsement.GetItemCheckState(i) = CheckState.Checked Then
If Not .BOF Then
Do While Not .EOF
endorsement = rs.Fields.Item("description").Value.ToString
'---Stores the rate for the selected item
endvalue = rs.Fields.Item("id").Value.ToString
'---add the the endvalue to the current rate
Grid.Columns("Rate").Value = Val(endvalue) + rate
LoadRate(formcodeval, township, range, cropclass, cropname, stateid, countyid)