Loading a form

  • Thread starter Thread starter juli jul
  • Start date Start date
J

juli jul

Hello,
I created a form and excpected to see in a windows designer generated
code something like this:
this.Load += new System.EventHandler(this.Form1_Load);

as I saw in other projects.
But I don't see it and I need it in order to do things while the form
loading.
How can I add it and where it appears?
Thank you!
 
Hi juli,

If you double click on the Form the designer will add a handler to the default event for that control as well as the method.

You can also add it manually

this.Load += new System.EventHandler(this.Form1_Load);

private void Form1_Load(object sender, EventArgs e)
{
// Add code here
}

Or, since you most likely are coding inside the Form1 class

protected override void OnLoad(EventArgs e)
{
// Add code here, note no += EventHandler needed
}
 
Back
Top