473,704 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 programmaticall y 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
3 3988
"JohnR" <Jo******@hotma il.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.MouseEn ter,
Button2.MouseEn ter, ...', 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
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
Thanks for the replies, I will use the addhandler at runtime.

John
"JohnR" <Jo******@hotma il.com> wrote in message
news:T1Wve.3202 $Q27.1576@trndn y02...
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 programmaticall y 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6669
by: 2003et | last post by:
How To Create Transparent Windows Controls? Thanks
1
1201
by: Csharper95 | last post by:
I am currently working on completing a program that someone else started. The problem (when the program is running): When more than one document/file is opened, the mouse changes the active window simply by moving it (the mouse pointer) over the work area (not the title bar) of one of the open windows. When of course, it's supposed to activate when there is a mouse click on the inactive window. In the Program:
18
3066
by: jrhoads23 | last post by:
Hello, I am trying to find a way to tell if an .NET windows forms Button (System.Windows.Forms.Button) is "depressed" (pushed down). For my application, I can not use a check box control set to button style, I must use a System.Windows.Forms.Button. I can not find a way to tell when it is momentaraly pressed. I tried calling the API SendMessage with the button handle and BM_GETSTATE to get the state of the button. This will only return...
12
1471
by: Peter | last post by:
I'm looking to create multiple textboxs that change to a light blue on focus. What is the most efficient way to do this? -Peter
0
1526
by: Pucara | last post by:
Hi all, I have noticed that the picturebox object doesnt' fire correctly the mouseEnter mouseLeave events. The problem is seen ONLY when you show a form more than once. You can reproduce it easily: create a form, drop a picturebox, and handle the events mouseEnter, mouseLeave (of the picturebox), change the image for example. Then do something like this dim frm as new form1
5
1326
by: Simon Verona | last post by:
I have an inherited datagrid which has a "double-click" even which returns the row that has been clicked on - this can be consumed by the form (etc) that hosts the control to open another window that shows more detailed information on that line. I want to be able to change the mouse pointer when the user hovers over the control, to make it clearer that the rows can be clicked on.... However, I only want to change the pointer if I know...
8
2108
by: gs | last post by:
I was able to set tooltips on objects other than main menu. I would like to get the effect of tooltip or microhelp in the bottom status bar when the mouse is hovering over a submenu item. How do I do that? For example in outlook express, when one expand a main menu item and holds mouse over one of the enable sub menu item, one would see some sort microhelp text in the status bar in the bottom
7
1982
by: Martijn Mulder | last post by:
There are 2 ways to hook an event to a method. For example, to hook the MouseEnter-event, you can use MouseEnter+=OnMouseEnter; or MouseEnter+=new System.EventHandler(OnMouseHandler); Both work well, as demonstrated by the small program below, where the
12
3795
by: Marc | last post by:
Hi, How can i increase the mousehover event timer? AddHandler NewBtn.MouseHover, AddressOf Shownotes Private Sub Shownotes(ByVal sender As System.Object, ByVal e As System.EventArgs) MsgBox("ttt") Thanks!!!
0
8767
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9136
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9030
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7893
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4439
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4703
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3137
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.