简体   繁体   中英

How do I add a Form Load event using the form designer in C# 2015? (like double clicking)?

I am new to C# in Visual Studio 2015. I just realized that the old classical way of adding event handlers by double-clicking on the item no longer works for some items like the form (or the Window).

After some Google searches I still can't figure out a way to add the Load event of the form using the designer.

Do I have to manually write code for that unlike in Visual Basic in Visual Studio 2005?

You can set the Load event of a Control from its properties window here . You create the

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

event in your form class, and fill in its name (Form1_Load) where the arrow points in the picture.

Doing it manually would be something like:

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

considering that you created the Form1_Load event.

But on top of all that, double clicking should work.

You may have an issue with your instillation. However, select the form and go to the actions window and select load. This should give the desired result

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM