* Merge winforms framework content to working branch (#14) * Breadcrumb / TOC / Move net5 to net folder (#15) * change path from net5 to net * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Add .net 5 winforms placeholder article (#16) * added some metadata and adjusted net5 placeholder * corrections * corrections * corrections * Test1 * Swapping landing page vs concept * fix links * Fix links * Fix desc
2.7 KiB
title, ms.date, f1_keywords, helpviewer_keywords, ms.assetid
| title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||||
|---|---|---|---|---|---|---|---|---|
| How to: Align and Stretch a Control in a TableLayoutPanel Control | 03/30/2017 |
|
|
7dc1a157-6fee-4995-8ebc-b65bdc0909a8 |
How to: Align and Stretch a Control in a TableLayoutPanel Control
You can align and stretch controls in a xref:System.Windows.Forms.TableLayoutPanel with the xref:System.Windows.Forms.Control.Anchor%2A and xref:System.Windows.Forms.Control.Dock%2A properties.
Align and stretch a control
-
In Visual Studio, drag a xref:System.Windows.Forms.TableLayoutPanel control from the Toolbox onto your form.
-
Drag a xref:System.Windows.Forms.Button control from the Toolbox into the upper-left cell of the xref:System.Windows.Forms.TableLayoutPanel control. The xref:System.Windows.Forms.Button control is centered in the cell.
-
Set the value of the xref:System.Windows.Forms.Button control's xref:System.Windows.Forms.Control.Anchor%2A property to
Left,Right. The xref:System.Windows.Forms.Button control stretches to match the width of the cell. -
Set the value of the xref:System.Windows.Forms.Button control's xref:System.Windows.Forms.Control.Anchor%2A property to
Top,Bottom. The xref:System.Windows.Forms.Button control stretches to match the height of the cell. -
Set the value of the xref:System.Windows.Forms.Button control's xref:System.Windows.Forms.Control.Dock%2A property to xref:System.Windows.Forms.DockStyle.Fill. The xref:System.Windows.Forms.Button control expands to fill the cell.
-
Set the value of the xref:System.Windows.Forms.Button control's xref:System.Windows.Forms.Control.Dock%2A property to xref:System.Windows.Forms.DockStyle.None. The xref:System.Windows.Forms.Button control returns to its original size and moves to the upper-left corner of the cell. The Windows Forms Designer has set the xref:System.Windows.Forms.Control.Anchor%2A property to
Top, Left. -
Set the value of the xref:System.Windows.Forms.Button control's xref:System.Windows.Forms.Control.Anchor%2A property to
Bottom,Right. The xref:System.Windows.Forms.Button control moves to the lower-right corner of the cell. -
Set the value of the xref:System.Windows.Forms.Button control's xref:System.Windows.Forms.Control.Anchor%2A property to xref:System.Windows.Forms.AnchorStyles.None. The xref:System.Windows.Forms.Button control moves to the center of the cell.