Groups | Blog | Home
all groups > vb.net > may 2005 >

vb.net : Multiple Controls in a single Sub?


Justin
5/9/2005 4:43:12 PM
Take this example:

Private Sub nPnlProfile_MouseHovers(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles comboProfileName.MouseHover,
btnDelete.MouseHover, btneditFolderPath.MouseHover,
comboThumbQuality.MouseHover, comboThumbSize.MouseHover,
btnAddFile.MouseHover, ListBox1.MouseHover, btnRemove.MouseHover

'Do Something

End Sub

Is there a way to detect which control is firing so I can run code for that
control.mousehover? I figured that would be better then having a hundred
some subs.

Is this an appropriate way to code?

Thanks,
Justin

Ken Tucker [MVP]
5/9/2005 8:26:22 PM
Hi,

Sender is the control which fired the event.

If sender is listbox1 then
'do something
elseif sender is comboprofilename then
'do something else
......etc

Ken
----------------
[quoted text, click to view]
Take this example:

Private Sub nPnlProfile_MouseHovers(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles comboProfileName.MouseHover,
btnDelete.MouseHover, btneditFolderPath.MouseHover,
comboThumbQuality.MouseHover, comboThumbSize.MouseHover,
btnAddFile.MouseHover, ListBox1.MouseHover, btnRemove.MouseHover

'Do Something

End Sub

Is there a way to detect which control is firing so I can run code for that
control.mousehover? I figured that would be better then having a hundred
some subs.

Is this an appropriate way to code?

Thanks,
Justin


Justin
5/10/2005 9:17:46 AM
That's exactly what I needed. Thanks Ken!

Private Sub nPnlProfile_MouseHovers(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles comboProfileName.MouseHover,
btnDelete.MouseHover, btneditFolderPath.MouseHover,
comboThumbQuality.MouseHover, comboThumbSize.MouseHover,
btnAddFile.MouseHover, btnRemove.MouseHover, listFileTypes.MouseHover


If sender Is comboProfileName Then nPnlProfile.FooterText = "Select an
existing name from the drop down list or input a new profile name then hit
ENTER"
If sender Is btnDelete Then nPnlProfile.FooterText = "Select this button to
delete the currently selected profile"
If sender Is btneditFolderPath Then nPnlProfile.FooterText = "Select the
folder path your templates"
If sender Is comboThumbQuality Then nPnlProfile.FooterText = "Select the
compression quality for your thumbnails"
If sender Is comboThumbSize Then nPnlProfile.FooterText = "Select the size
you wish your thumbnails to be"
If sender Is btnAddFile Then nPnlProfile.FooterText = "Add a file mask to
the search paramters"
If sender Is listFileTypes Then nPnlProfile.FooterText = "This area will
show you the file types the currently selected profile will search for"
If sender Is btnRemove Then nPnlProfile.FooterText = "Select a file type
then select remove to remove that file type from the list"
.........

End Sub


[quoted text, click to view]

AddThis Social Bookmark Button