Handling the button's Click event involves two things. The first is creating a handler function with the appropriate signature; we've named this function button_Click. The signature of the vast majority of .NET events is a function that returns nothing and takes two parameters: an object that represents the sender of the event (our button, in this case), and an instance of a System.EventArgs object (or an object that derives from the EventArgs class). The second thing that's needed to subscribe to an event in C# is shown by the use of the "+=" operator in the MyFirstForm constructor. This notation means that we'd like to add a function to the list of all the other functions that care about a particular event on a particular object, and that requires an instance of an EventHandler delegate object. A delegate is a class that translates invocations on an event into calls on the functions that have subscribed to the event. For this particular event, we have the following logical delegate and event definitions elsewhere in the .NET FCL:
Thursday, October 15, 2020
Subscribe to:
Post Comments (Atom)
Application Settings As some applications get more sophisticated, users expect more from all their applications. For example, some applicat...
-
Before we start the drag-and-drop extravaganza that the Designer enables, let's take a look at a slightly abbreviated version of the co...
-
In the Designer, you can drop and arrange any controls on the user control that you like, setting their properties and handling events jus...
-
Setting the Dock Property As an example, the form in shows the Dock properties for a status bar, a tree view, and a list view, the lat...
No comments:
Post a Comment