开发者

How to set a columnspan in tableLayoutPanel

开发者 https://www.devze.com 2023-02-14 05:28 出处:网络
I am using a tableLayoutPanel which consist of two rows. In first row I want two columns, and in second row I on开发者_如何学JAVAly need one column. How can I do this?With the designer: put a control

I am using a tableLayoutPanel which consist of two rows. In first row I want two columns, and in second row I on开发者_如何学JAVAly need one column. How can I do this?


With the designer: put a control in the 2nd row and set its ColumnSpan property to 2.

In code:

    public Form1() {
        InitializeComponent();
        var button = new Button();
        button.Dock = DockStyle.Fill;
        tableLayoutPanel1.Controls.Add(button);
        tableLayoutPanel1.SetCellPosition(button, new TableLayoutPanelCellPosition(0, 1));
        tableLayoutPanel1.SetColumnSpan(button, 2);
    }


If you are on visual studio, just set the ColumnSpan property of control you want to put in row 2 to '2' and it will take care of that.

0

精彩评论

暂无评论...
验证码 换一张
取 消