Generic click event?

archer_coal

Regular
Joined
Apr 4, 2003
Messages
96
I have a bunch of listboxes on a form
if another listbox is clicked i want the previous listbox.selectedindex to = 0 (no longer selected)

Is there an easy way to do this or do i have to code all of my listboxes to look for another click event?
dang control arrays would have been so easy here but it's too late for that now .

:D
 
Well, you can do just about everything ControlArrays could in WindowsForms

In your case, just have all of your ListBox's SelectedIndexChanged Events get handled by the same Method. If you're not sure how to do that, let me know and I'll help you with it...also, if you're using VB.NET or C#

That being said, I'm almost done with a new ControlArray Component that I started work on last week, that has all the same functionality of the originaly VB6 Control Arrays (but more .NET like) and will be posting it up soon on GotDotNet and the WindowsForms.net website. It has full design time support (like right click, add to control array, custom UITypeEditor, etc) and all the code will be posted with it, so look for that half way soon.
 
RE:

That controlarry component sounds nice, ill keep my eyes open for it. I'm using vb.net for this project and listbox problem and i'm not sure how to go about having the Listbox.Selectedindexchanged event handled by the same method. Any Tips or tutorials would be greatly appreciated.
Thanks
 
Visual Basic:
Public Sub ListBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ListBox1.SelectedIndexChanged, ListBox2.SelectedIndexChanged, ListBox3.SelectedIndexChanged
     MessageBox.Show(DirectCast(sender, ListBox).Name)
End Sub
 
Back
Top