How to: Align and Stretch a Control in a TableLayoutPanel Control
You can align and stretch controls in a TableLayoutPanel with the Anchor and Dock properties.
Align and stretch a control
In Visual Studio, drag a TableLayoutPanel control from the Toolbox onto your form.
Drag a Button control from the Toolbox into the upper-left cell of the TableLayoutPanel control. The Button control is centered in the cell.
Set the value of the Button control's Anchor property to
Left,Right
. The Button control stretches to match the width of the cell.Set the value of the Button control's Anchor property to
Top,Bottom
. The Button control stretches to match the height of the cell.Set the value of the Button control's Dock property to Fill. The Button control expands to fill the cell.
Set the value of the Button control's Dock property to None. The Button control returns to its original size and moves to the upper-left corner of the cell. The Windows Forms Designer has set the Anchor property to
Top, Left
.Set the value of the Button control's Anchor property to
Bottom,Right
. The Button control moves to the lower-right corner of the cell.Set the value of the Button control's Anchor property to None. The Button control moves to the center of the cell.
See also
.NET Desktop feedback