亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

動態添加 usercontrol 到 tablelayout

動態添加 usercontrol 到 tablelayout

C#
弒天下 2022-11-22 16:38:02
例如我有這樣的用戶控件。我想將其動態添加到已知字段(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" });

您可以將控件的屬性放在里面{ }


查看完整回答
反對 回復 2022-11-22
  • 1 回答
  • 0 關注
  • 122 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號