Files
docs-desktop/dotnet-desktop-guide/framework/winforms/controls/how-to-align-and-stretch-a-control-in-a-tablelayoutpanel-control.md
T
Andy De George c0ba284473 Initial winforms content migrated (#18)
* 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
2020-09-01 16:26:21 -07:00

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
net.ComponentModel.StyleCollectionEditor.TLP.AlignStretchCtrl
TableLayoutPanel control [Windows Forms], stretching controls
controls [Windows Forms], stretching
controls [Windows Forms], aligning
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

  1. In Visual Studio, drag a xref:System.Windows.Forms.TableLayoutPanel control from the Toolbox onto your form.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

  8. 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.

See also