c# tablelayoutpanel

  Winforms Tablelayoutpanel is used to align winform controls in rows and columns. Winforms tablelayoutpanel control

When you add a control in tablelayoutpanel control cell, by default is positions in top left control of the cell, to change it to the required postion use the control's anchor property as below

//Use anchor property of control, to set the position of the control in tablelayoutpanel cell
            this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)
                ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)
                ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)
                ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));

TableLayoutPanel RowSpan or ColumnSpan

To span control across multiple rows or columns , use contro'ls rowspan or columnspan property. The below lines of code can be used to span control across multiple rows or multiple columns.

//To span control across 3 rows
            this.tableLayoutPanel1.SetRowSpan(this.button2, 3);
            //To span control across 2 columns
            this.tableLayoutPanel1.SetColumnSpan(this.label1, 2);

tablelayout panel column span, tablelayout panel row span, align child controls, c# tablelayoutpanel