次のコードはSee Gif Hereで動作します。なぜあなたはチェックボックスでラベルを開始しようとしていますか?パネル
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
var uc = new UserControl1();
panel1.Controls.Add(uc);
}
}
UserControl1の部分クラスにコントロールを追加します
public partial class UserControl1 : TableLayoutPanel
{
public RichTextBox res;
public CheckBox checkBox;
public RichTextBox steps;
public UserControl1()
{
InitializeComponent();
res = new RichTextBox();
checkBox = new CheckBox();
steps = new RichTextBox();
this.ColumnCount = 3;
this.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 50F));
this.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.Controls.Add(this.checkBox, 0, 0);
this.Controls.Add(this.steps, 1, 0);
this.Controls.Add(this.res, 2, 0);
}
}
フォームが
partial class UserControl1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label = new System.Windows.Forms.Label();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.SuspendLayout();
//
// label
//
this.label.AutoSize = true;
this.label.Location = new System.Drawing.Point(81, 74);
this.label.Name = "label";
this.label.Size = new System.Drawing.Size(35, 13);
this.label.TabIndex = 0;
this.label.Text = "label1";
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Location = new System.Drawing.Point(84, 141);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(200, 100);
this.tableLayoutPanel1.TabIndex = 1;
//
// UserControl1
//
this.Controls.Add(this.tableLayoutPanel1);
this.Controls.Add(this.label);
this.Name = "UserControl1";
this.Size = new System.Drawing.Size(602, 329);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label;
private System.Windows.Forms.RichTextBox result;
private System.Windows.Forms.RichTextBox step;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
}
あなたは私のUserControl1クラスの他の部分クラスを示してもいいですか?私のケースでは、StepPanelクラスでInitializeComponent()を呼び出すことができないので、もしあれば、 – ASayed
私はあなたのコードを渡って来た唯一の問題は、あなたがチェックボックスでラベルを開始しようとしているということです。それがちょうど悪い命名なら、おそらくすべてのファイルを閉じて、プロジェクトを再構築してみてください。ビルド – DuckSoy
と呼ばれる上部のツールバーでこれを見つけることができます。program.cs以外のコードはすべて – DuckSoy