Multiple Controls in a single Sub?

  • Thread starter Thread starter Justin
  • Start date Start date
J

Justin

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
 
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
----------------
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top