例如我有這樣的用戶控件。我想將其動態添加到已知字段(tablelayout6)。我需要如何編輯此用戶控件才能實現我的目標?我不知道如何參考我的表格布局。public class Userblock : UserControl{ TextBox textName; Label labelName; cCheckedListBox listtablelayout6; public Userblock() { InitializeComponent(); } public void InitializeComponent() { textName = new System.Windows.Forms.TextBox(); labelName = new System.Windows.Forms.Label(); labelName.Text = "Name:"; listtablelayout6.Size = new System.Drawing.Size(112, 100); Controls.AddRange(new System.Windows.Forms.Control[] { labelName, labelAddress, listtablelayout6 }); }}
1 回答

泛舟湖上清波郎朗
TA貢獻1818條經驗 獲得超3個贊
這很簡單..
yourTableLayoutName.Controls.Add(new Button { Text = "I'm a Button" }); yourTableLayoutName.Controls.Add(new Label { Text = "I'm a Label" });
您可以將控件的屬性放在里面{ }
- 1 回答
- 0 關注
- 122 瀏覽
添加回答
舉報
0/150
提交
取消