[RESOLVED] listbox cotrol array select/unselect
Hi guys
got a real silly question i have a set of 6 listboxs in a control array, i want to set them in such a way that when i click one the others are unclicked(unhighlighted). i know i can do this with loads of ifs and end ifs but i am also sure that there is another way with like a line or so of code its just my mind is blank?
any ideas?
Re: listbox cotrol array select/unselect
I'm not sure what you mean by unclicked(unhighlighted), so I will show an example of Enabled instead - based on what you said you should be able to work it out from there.
Code:
Private Sub lstMyArray_Click(Index As Integer)
Dim ctlTempList As Control
For Each ctlTempList In lstMyArray
If ctlTempList.Index <> Index Then
ctlTempList.Enabled = False
End If
Next ctlTempList
End Sub
Re: listbox cotrol array select/unselect
Yep worked it and i was so close yet so far thanks
1 Attachment(s)
Re: [RESOLVED] listbox cotrol array select/unselect
Bah almost works any ideas
Code:
Dim ctl As Control
For Each ctl In LstOtput
If Not ctl.Index <> Index Then
ctl.ListIndex = "-1"
End If
Next ctl
basically when you click a listbox the selected line turns blue, if so with numnerous listboxs clicked one after the other they all have a selected line visible in blue. the code you supplied almost works as above but on clicking a listbox it unselects all of them inclueding the one clicked then if you click it once more it selects the list clicked.
the effect i am after is i suppose like a set of radio buttons in a frame when one is selected the others are unselected.
Attached from as example
Re: [RESOLVED] listbox cotrol array select/unselect
Jeez i am such a noob have it firing on click this needed to happen on got focus
thanks again
Re: [RESOLVED] listbox cotrol array select/unselect
Ah yes, I see what you meant now.
To make it work, simply use the _GotFocus event instead of _Click (edit: as you found out already!)
Note that you aren't setting the ListIndex properly.. it is a Numeric property, so you should not be passing it a String (ie: it should be ctl.ListIndex = -1 )
Re: [RESOLVED] listbox cotrol array select/unselect