|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
can you create one "MouseEnter" event handler for multiple controls on a form?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. "JohnR" <JohnR***@hotmail.com> schrieb: You can either add the handlers at runtime in the 'Handles' part of 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. '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/> JohnR,
In this message is the standard sample that I made for this. http://groups-beta.google.com/group/microsoft.public.dotnet.languages.vb/msg/cd2cf9f1e2e947da?hl=en I hope this helps, Cor Thanks for the replies, I will use the addhandler at runtime.
John "JohnR" <JohnR***@hotmail.com> wrote in message news:T1Wve.3202$Q27.1576@trndny02...Show quoteHide quote >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. > |
|||||||||||||||||||||||