题外话:我们来研究一下拖动的控件生成的代码
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
///
private void InitializeComponent()
{
this.btnSave = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// btnSave
//
this.btnSave.Location = new System.Drawing.Point(121, 202);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(75, 23);
this.btnSave.TabIndex = 0;
this.btnSave.Text = "点击";
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(61, 107);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 21);
this.textBox1.TabIndex = 1;
//
// 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.Controls.Add(this.btnSave);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.TextBox textBox1;
我们可以理解到标记颜色的地方其实就是声明了一个按钮和文本框然后,设置位置,文本的名称,控件的颜色等等,一般的属性,我们都是可以通过鼠标右键来进行设置【属性】的,再次记住一句话“拖控件不是万能的”。
好了,谢谢观看。