C# event

event is a message produced by a specific action. For example, mouse clicked, key pressed, button clicked, data arrived etc.

private void testButtonOnClick(object sender, EventArgs e)
{
...
}

event handling methods such as button clicks usually are defined in frmMain class and in InitializeComponent() method:
partial class frmMain
{
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
this.openDialog = new System.Windows.Forms.OpenFileDialog();
...
this.testButton.Name = "testButton";
this.testButton.Size = new System.Drawing.Size(221, 22);
this.testButton.Text = "&Test";
this.testButton.Visible = true;
this.testButton+= new System.EventHandler(this.testButtonOnClick);
...
}
}



endmemo.com © 2024  | Terms of Use | Privacy | Home