winform窗体的生命周期和事件加载顺序是什么?
2个回答
展开全部
winform窗体的生命周仔薯期和事件加载顺序,唯亏如下:
1.窗体启动:
Control.HandleCreated
Control.BindingContextChanged
Form.Load
Control.VisibleChanged
Form.Activated
Form.Shown
2.窗体关闭:
Form.Closing
Form.FormClosing
Form.Closed
Form.FormClosed
Form.Deactivate
指戚神 3.控件焦点与验证事件:
Enter
GotFocus
Leave
Validating
Validated
LostFocus
4.鼠标周期:
Enter
GotFocus
LostFocus
Leave
Validating
Validated
1.窗体启动:
Control.HandleCreated
Control.BindingContextChanged
Form.Load
Control.VisibleChanged
Form.Activated
Form.Shown
2.窗体关闭:
Form.Closing
Form.FormClosing
Form.Closed
Form.FormClosed
Form.Deactivate
指戚神 3.控件焦点与验证事件:
Enter
GotFocus
Leave
Validating
Validated
LostFocus
4.鼠标周期:
Enter
GotFocus
LostFocus
Leave
Validating
Validated
展开全部
对于一个WinForm程序,坦迹如果是用VS自动创建的,那么程序的入口在这里
static class Program
{
/// <颤掘summary>
/// 应用程序的主入口让洞并点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
最后一句,new Form1();调用了Form1的构造函数,而Form1的构造函数的内容是:
public Form1()
{
InitializeComponent();
}
调用了InitializeComponent();,这个函数内容是:
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(59, 12);
this.label1.TabIndex = 0;
this.label1.Text = "C#_Window";
//
// button1
//
this.button1.Location = new System.Drawing.Point(205, 238);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "执行";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// notifyIcon1
//
this.notifyIcon1.Text = "notifyIcon1";
this.notifyIcon1.Visible = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
窗体的控件定义如下:
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.NotifyIcon notifyIcon1;
static class Program
{
/// <颤掘summary>
/// 应用程序的主入口让洞并点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
最后一句,new Form1();调用了Form1的构造函数,而Form1的构造函数的内容是:
public Form1()
{
InitializeComponent();
}
调用了InitializeComponent();,这个函数内容是:
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(59, 12);
this.label1.TabIndex = 0;
this.label1.Text = "C#_Window";
//
// button1
//
this.button1.Location = new System.Drawing.Point(205, 238);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "执行";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// notifyIcon1
//
this.notifyIcon1.Text = "notifyIcon1";
this.notifyIcon1.Visible = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
窗体的控件定义如下:
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.NotifyIcon notifyIcon1;
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询