Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is the checkbox of listbox item checked? 1

Status
Not open for further replies.

PhilX

Programmer
Apr 27, 2002
13
0
0
US
I have a listbox which has the style property set to 1 (checkbox). How can I tell whether the item is checked and/or selected?

TIA
 
If the style is set to checkbox the selected property is the the state of the checkbox. If it is not a checkbox style then the highlighted text is the selected item. Try this code:

Private Sub List1_Click()
Dim iX As Long

For iX = 0 To List1.ListCount - 1
Print List1.Selected(iX)
Next
End Sub

Hope this helps. Anything is possible, the problem is I only have one lifetime.
[cheers]
 
Thank you Katherine, but I'm using the regular ListBox in VB6, which does not have the SelectedObjectCollection. The CheckedListBox looks interesting, but I have not yet moved to .NET.

Thank you too, Foada. Your succinct answer was helpful. I've noticed that a listbox (with Style=1)item can be selected (highlighted) and/or checked. However, I can't find how to determine which, if any, item is highlighted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top