形态构造VS的Form_Load [英] Form constructor vs Form_Load

查看:133
本文介绍了形态构造VS的Form_Load的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我一个窗体构造函数和在Form_Load方法之间的区别?

Whats the difference between a form constructor and the form_Load method?

请告诉我放置物品在一个相较于其他的,虽然过程?

Whats your though process for placing items in one vs the other?

推荐答案

在创建表单,你是否永远不显示它的代码在构造函数中立即运行。在 Form.Load 事件运行的代码是一个事件处理程序,所以实际上你可以在其他类(已订阅的形式)运行代码有代码。同样,您可以(从窗体)使用 Form.OnLoad方法运行代码。

Code in the constructor runs immediately when you create the form, whether or not you ever display it. Code running in the Form.Load event is an event handler, so you can actually have code in other classes (which have subscribed to the form) run code there. Similarly, you can (from the form) use the Form.OnLoad method to run code.

窗体的Load事件(的OnLoad覆盖的方法,这往往是形式本身就是一个更好的选择)的形式被初始化后运行。这通常具有优势,因为所有形式的控件已经被构建,并且更重要的是,所有的形式布局的发生

The form's Load event (and OnLoad overridable method, which is often a better choice in the form itself) runs after the form has been initialized. This often has advantages, since all of the form's controls have already been constructed, and more importantly, all of the form layout has occurred.

这篇关于形态构造VS的Form_Load的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆