创建组框构造函数的方法 Visual Studio? (菜鸟问题)
Way to create a Group box constructor Visual Studio? (Rookie question)
我创建了一个包含我想要的所有内容的组框(见图)- 现在有没有办法(IE - 菜单选项)为此创建一个构造函数?寻找与此类似的东西(https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.groupbox.-ctor?view=netframework-4.7.2)。唯一的区别是我预先制作了我的组框以便我可以将其可视化,现在我需要一个构造函数以便我可以将它创建到一个数组中。我希望这对你们有意义 - 我是 Visual Studios 的新手(感谢简单的回答)。谢谢。
如果您查看表单的 Designer 文件(它列在解决方案资源管理器 window 中),您将看到为您的组框生成的代码,以及表单上的任何其他控件。它看起来像这样:
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Location = new System.Drawing.Point(76, 28);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(200, 100);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 261);
this.Controls.Add(this.groupBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
我创建了一个包含我想要的所有内容的组框(见图)- 现在有没有办法(IE - 菜单选项)为此创建一个构造函数?寻找与此类似的东西(https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.groupbox.-ctor?view=netframework-4.7.2)。唯一的区别是我预先制作了我的组框以便我可以将其可视化,现在我需要一个构造函数以便我可以将它创建到一个数组中。我希望这对你们有意义 - 我是 Visual Studios 的新手(感谢简单的回答)。谢谢。
如果您查看表单的 Designer 文件(它列在解决方案资源管理器 window 中),您将看到为您的组框生成的代码,以及表单上的任何其他控件。它看起来像这样:
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Location = new System.Drawing.Point(76, 28);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(200, 100);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 261);
this.Controls.Add(this.groupBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}