Page update date :
Page creation date :

Events are meant to be commensurate with the user's interaction when they do so. The programmer can skip processing to a specified method when the event occurs. It is almost always used in tools etc.

As an exercise, let's create a program that displays a message box when the form is clicked with the mouse.

The first thing to do is display the designer of the form. Click "MainForm.cs [Design]" from the tab above. If it is closed, double-click "MainForm .cs" from the solution explorer. Right-click "Show Designer" is also good.



When the designer appears, open "Properties" (before that, click on the form to focus on it. Otherwise, you may not see it as shown below), press the "Event (lightning bolt button)" above the property window.


Since the items like the following are displayed, please double-click the part of the character of "MouseDown".


Then you go to the code editor and see that a new method has been added.


This "MainForm_MouseDown" method is called when you click the mouse. Now, try putting the following code inside this method:



Try running it. I think clicking on the form will bring up the dialog below.


The event looks like this. For the time being, I'll remove this event for testing purposes. To delete, open the event from the previous properties, right-click on "MouseDown" and select "Reset". This prevents this event from being executed. The code remains in the code file, so delete it as is.