--- title: "How to: Anchor and Dock Child Controls in a FlowLayoutPanel Control" description: Learn how to programmatically anchor and dock child controls in a Windows Forms FlowLayoutPanel control. ms.date: "03/30/2017" helpviewer_keywords: - "layout [Windows Forms], child controls" - "FlowLayoutPanel control [Windows Forms], child controls" - "controls [Windows Forms], child" - "child controls [Windows Forms], anchoring and docking" ms.assetid: a2bcdfca-9b63-45e6-9c0e-3411015cba98 --- # How to: Anchor and Dock Child Controls in a FlowLayoutPanel Control The control supports the and properties in its child controls. ### To anchor and dock child controls in a FlowLayoutPanel control 1. Create a control on your form. 2. Set the of the control to **300**, and set its to . 3. Create two controls, and place them in the control. 4. Set the of the first button to **200**. 5. Set the property of the second button to . > [!NOTE] > The second button assumes the same width as the first button. It does not stretch across the width of the control. 6. Set the property of the second button to `None`. This causes the button to assume its original width. 7. Set the property of the second button to `Left, Right`. > [!IMPORTANT] > The second button assumes the same width as the first button. It does not stretch across the width of the control. This is the general rule for anchoring and docking in the control: for vertical flow directions, the control calculates the width of an implied column from the widest child control in the column. All other controls in this column with or properties are aligned or stretched to fit this implied column. The behavior works in a similar way for horizontal flow directions. The control calculates the height of an implied row from the tallest child control in the row, and all docked or anchored child controls in this row are aligned or sized to fit the implied row. ## Example The following illustration shows four buttons that are anchored and docked relative to the blue button in a . The is . ![FlowLayoutPanel anchoring](./media/net-flpanchorexp.gif "NET_FLPanchorExp") The following illustration shows four buttons that are anchored and docked relative to the blue button in a . The is . ![FlowLayoutPanel anchoring](./media/vs-flpanchor2.gif "VS_FLPanchor2") The following code example demonstrates various property values for a control in a control. [!code-csharp[System.Windows.Forms.FlowLayoutPanel.AnchorExampleForm#1](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.FlowLayoutPanel.AnchorExampleForm/CS/FlpAnchorExampleForm.cs#1)] [!code-vb[System.Windows.Forms.FlowLayoutPanel.AnchorExampleForm#1](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FlowLayoutPanel.AnchorExampleForm/VB/FlpAnchorExampleForm.vb#1)] ## Compiling the Code This example requires: - References to the System, System.Data, System.Drawing and System.Windows.Forms assemblies. ## See also - - [FlowLayoutPanel Control Overview](flowlayoutpanel-control-overview.md)