September 6, 2002 - Handling Click Events in a Windows form
September 6, 2002 Handling Click Events in a Windows form Tips: September 2002
Yehuda Shiran, Ph.D.
|
button1
and the event handler is button1_Clicked
:
button1.add_Click(button1_Clicked);
Then, we define the event handler to pop-up an alert box whenever the button is clicked:
function button1_Clicked(o : Object, e : EventArgs) {
MessageBox.Show(o.Name());
}
The package is ButtonClickPkg
and the class is ButtonClickCls
. We pop up the Windows form by calling the Application.Run()
method:
Application.Run(new ButtonClickPkg.ButtonClickCls());
You should get the following Windows form:To learn more about JScript .NET and ASP.NET, go to Column 117, JScript .NET, Part XI: Creating Windows Forms.