InitializeComponent()用于初始化窗体上控件。
转到它的定义函数可以看到:
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(29, 34);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(204, 21);
this.textBox1.TabIndex = 0;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}Form1窗体上有一个textbox1,并且设置其属性。
本文介绍了如何使用InitializeComponent()方法初始化Windows应用程序中的控件,以实现快速创建和配置控件的功能。通过实例展示了如何创建一个包含文本框的简单窗体,并设置其属性。
2万+

被折叠的 条评论
为什么被折叠?



