In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to use the parameters in the C# event handler". Many people will encounter such a dilemma in the operation of actual cases. next, let the editor lead you to learn how to deal with these situations! I hope you can read it carefully and be able to achieve something!
1. Is the event source, indicating the component that triggered the event
If (button/label/listview...), for example, if you click button, then sender is button
2. EventArgs is an event parameter, which is used to assist you in dealing with events
For example, if you click on the form with the mouse, then EventArgs will include the location of the click, and so on.
Example:
Private void label1_MouseClick (object sender, MouseEventArgs e) {Label senderLabel = (Label) sender; / / according to the sender reference control senderLabel.Text = e.Button.ToString (); / / based on the button parameter in e, determine whether to press the left button or right button}
3. E represents the event object, which contains information about the event. E is just a customary name, of course, you can name it something else, you can write it as a b c d f g h i j.
4. E is a class that stores data for events. Different events e may be different
TreeNodeMouseClickEventArgs has the following attributes (from MSDN):
Name description
Button gets which mouse button was pressed. (inherited from MouseEventArgs.)
Clicks gets the number of times the mouse button is pressed and released. (inherited from MouseEventArgs.)
Delta gets a signed count of the number of brakes whose mouse wheel has been turned. The brake is a notch in the mouse wheel. (inherited from MouseEventArgs.)
Location gets the position of the mouse when the mouse event is generated. (inherited from MouseEventArgs.)
Node gets the node that was clicked.
X gets the x coordinate of the mouse when it generates a mouse event. (inherited from MouseEventArgs.)
Y gets the y coordinate of the mouse when the mouse event is generated. (inherited from MouseEventArgs.)
5. The content of this e of different events is different, for example, the event of mouse movement will contain the XMagi Y coordinate information of the mouse, if it is a keyboard event, this e will contain information about which key you are currently pressing, whether you have pressed the Ctrl key, alt key, and so on.
These are some of the parameters at the time of the event. This parameter is of different types and contains different information for different events.
This is the end of the introduction to "how to use parameters in C# event handlers". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.