In my project InitializeComponent (); method used several times. My Question is, what exactly is the Initialize Component method doing?
问问题
137 次
1 回答
1
if you look at your file in VS you can see a little "+" sign next to them and open that and the designer. there you will find the InitializeComponent
method that start the controls you've put in your form
the InitializeComponent
is generated by the VS according to the control you've put in your form when designed the form
for example if my form is look like this:
then InitializeComponent
will be:
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(85, 36);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "MY BTN";
this.button1.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
于 2013-07-29T06:09:19.253 回答