[RESOLVED] [02/03] CheckedListbox Question
I add items to a checkedListbox from a file as such:
Code:
While Not myInputString Is Nothing
currentFields = Split(myInputString, ",")
If currentFields(1) = "0" Then
lstApts.Items.Add(currentFields(0))
Else
lstApts.Items.Add(currentFields(0))
' I WANT TO CHECK THE ITEM THATS IN THIS ELSE CLAUSE
End If
rowCount += 1
' Read the next line.
myInputString = myStreamReader.ReadLine()
End While
As I am adding the item to the checkedListbox I want to set its property to checked if it is in the "Else" clause above. My issue is that once I add the item how do I refer to the item I just added in order to set its property without having to iterate through the whole box?
Re: [02/03] CheckedListbox Question
After you add an Item to the checked list box do this...
Code:
CheckedListBox1.Item(checkedlistbox1.items.count -1).checked = true
Re: [02/03] CheckedListbox Question
thanks.... i just found a simpler solution - the add method can be overloaded to take a second parameter - true or false
Code:
lstApts.Items.Add(currentFields(0), True)