The event concept
Event: something that happens, simply understood as an acquisition operation, which has an object raised.
View method: All events of the form can be viewed in the properties panel
Applications need to respond when events occur, so events are classified as:
Register events: Events must be registered for an object to be executed
Trigger event: Registered events must be triggered to occur.
Methods for adding events:
If you want to add a control to your form, just select the event you want to add in the event panel and double-click the space behind it. The corresponding event will be automatically generated. By default, the most commonly used event will be selected
An event is essentially a method
Common attributes:
Click | Click on the event |
---|---|
DoubleClick | Double-click the event |
FormColsed | Window closed (window already closed) |
KeyDown | When a key is pressed (the state of being pressed) |
KeyPress | This occurs when the user presses and releases a key |
KeyUp | Release the button |
Load | The window is loaded when it finishes running, and the event is triggered when the loading is complete |
MouseClick | The mouse to click |
MouseDoubleClick | Mouse click |
MouseDown | The mouse click |
MouseHover | Hover the mouse cursor |
MouseMove | Mouse movement form |
MouseUP | Release the mouse |
Adds a control to a form
For an application, controls are the building blocks of the user interface, and they are interactive
Another way to add controls: drag, pull, drag (one meaning)
Another way to Add a control is through the Add method of the Controls class on the form, in the following format:
Controls.add (control identifier);
Highly optimized code additions will make the program run faster!
Form display and Hide with Show method and Hide method to achieve, the format is as follows:
Form identifiers.Show();
Form identifier.Hide();