By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,133 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,133 IT Pros & Developers. It's quick & easy.

can you create one "MouseEnter" event handler for multiple controls on a form?

P: n/a
I have a form with a number of text boxes, comboboxes etc. What I would
like to do is create an event handler for the "mouseenter" event for each of
the controls whereby I display information about the control they just
entered (sort of like an extended tooltip). Now, I can certainly create a
separate mouseenter event for each control (too much work, and not very
clever), but what I would like to do is somehow create one event that would
trigger on the "mouseenter" of any control on the form (much less work, and
very clever). Hopefully, this event will pass a "sender" parameter where,
in the event handler, I can determine which control just got entered, and
display the appropriate message for the user. I have scanned all controls
on a form to do other things (formatting, etc), but if I pick up an
arbitrary control from the 'controls' collection how would I go about
defining a mouseenter event for it? If I can do that, I can loop thru all
the controls and programmatically create mouseenter events for them.

I have a feeling that this can somehow be done, but I'm at a loss as how to
go about it. Can anybody give me some ideas as to how this might be done.

Thanks.
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"JohnR" <Jo******@hotmail.com> schrieb:
I have a form with a number of text boxes, comboboxes etc. What I would
like to do is create an event handler for the "mouseenter" event for each
of the controls whereby I display information about the control they just
entered (sort of like an extended tooltip). Now, I can certainly create a
separate mouseenter event for each control (too much work, and not very
clever), but what I would like to do is somehow create one event that would
trigger on the "mouseenter" of any control on the form (much less work, and
very clever). Hopefully, this event will pass a "sender" parameter where,
in the event handler, I can determine which control just got entered, and
display the appropriate message for the user.


You can either add the handlers at runtime in the 'Handles' part of a
'MouseEnter' event handler ('... Handles Button1.MouseEnter,
Button2.MouseEnter, ...', or you can bind the handler to controls' events
using 'AddHandler' at runtime (see documentation).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

P: n/a
JohnR,

In this message is the standard sample that I made for this.

http://groups-beta.google.com/group/...e2e947da?hl=en

I hope this helps,

Cor
Nov 21 '05 #3

P: n/a
Thanks for the replies, I will use the addhandler at runtime.

John
"JohnR" <Jo******@hotmail.com> wrote in message
news:T1Wve.3202$Q27.1576@trndny02...
I have a form with a number of text boxes, comboboxes etc. What I would
like to do is create an event handler for the "mouseenter" event for each
of the controls whereby I display information about the control they just
entered (sort of like an extended tooltip). Now, I can certainly create a
separate mouseenter event for each control (too much work, and not very
clever), but what I would like to do is somehow create one event that would
trigger on the "mouseenter" of any control on the form (much less work, and
very clever). Hopefully, this event will pass a "sender" parameter where,
in the event handler, I can determine which control just got entered, and
display the appropriate message for the user. I have scanned all controls
on a form to do other things (formatting, etc), but if I pick up an
arbitrary control from the 'controls' collection how would I go about
defining a mouseenter event for it? If I can do that, I can loop thru all
the controls and programmatically create mouseenter events for them.

I have a feeling that this can somehow be done, but I'm at a loss as how
to go about it. Can anybody give me some ideas as to how this might be
done.

Thanks.

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.