This documentation is archived and is not being maintained.

FlowLayoutPanel Class

Represents a panel that dynamically lays out its contents horizontally or vertically.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public class FlowLayoutPanel : Panel, 

The FlowLayoutPanel control arranges its contents in a horizontal or vertical flow direction. Its contents can be wrapped from one row to the next, or from one column to the next. Alternatively, its contents can be clipped instead of wrapped.

You can specify the flow direction by setting the value of the FlowDirection property. The FlowLayoutPanel control correctly reverses its flow direction in right-to-left (RTL) layouts. You can also specify whether the contents of the FlowLayoutPanel control are wrapped or clipped by setting the value of the WrapContents property.

Any Windows Forms control, including other instances of FlowLayoutPanel, can be a child of the FlowLayoutPanel control. With this capability, you can construct sophisticated layouts that adapt to your form's dimensions at run time.

Docking and anchoring behaviors of child controls differ from the behaviors in other container controls. Both docking and anchoring are relative to the largest control in the flow direction. For more information, see How to: Anchor and Dock Child Controls in a FlowLayoutPanel Control.

The following example shows how to set the FlowDirection and WrapContents properties on a FlowLayoutPanel control. Paste the code into the Form1 source file. If your project contains a file named Form1.Designer.cs or Form1.Designer.vb, remove that file from the project. You may need to click the Show All Files button in Solution Explorer to see the designer file.

using System;
using System.Windows.Forms;

public class Form1 : System.Windows.Forms.Form
	private void wrapContentsCheckBox_CheckedChanged(
		System.Object sender, 
		System.EventArgs e)
        this.FlowLayoutPanel1.WrapContents = 

    private void flowTopDownBtn_CheckedChanged(
		System.Object sender, 
		System.EventArgs e)
        this.FlowLayoutPanel1.FlowDirection = FlowDirection.TopDown;

    private void flowBottomUpBtn_CheckedChanged(
		System.Object sender, 
		System.EventArgs e)
        this.FlowLayoutPanel1.FlowDirection = FlowDirection.BottomUp;

    private void flowLeftToRight_CheckedChanged(
		System.Object sender, 
		System.EventArgs e)
        this.FlowLayoutPanel1.FlowDirection = FlowDirection.LeftToRight;

    private void flowRightToLeftBtn_CheckedChanged(
		System.Object sender, 
		System.EventArgs e)
        this.FlowLayoutPanel1.FlowDirection = FlowDirection.RightToLeft;

#region " Windows Form Designer generated code " 

    public Form1() : base()

        //This call is required by the Windows Form Designer.

        //Add any initialization after the InitializeComponent() call


    //Form overrides dispose to clean up the component list. 
    protected override void Dispose(bool disposing)
        if (disposing)
            if (components != null)

	private System.Windows.Forms.FlowLayoutPanel FlowLayoutPanel1;
	private System.Windows.Forms.CheckBox wrapContentsCheckBox;
	private System.Windows.Forms.RadioButton flowTopDownBtn;
	private System.Windows.Forms.RadioButton flowBottomUpBtn;
	private System.Windows.Forms.RadioButton flowLeftToRight;
	private System.Windows.Forms.RadioButton flowRightToLeftBtn;
	private System.Windows.Forms.Button Button1;
	private System.Windows.Forms.Button Button2;
	private System.Windows.Forms.Button Button3;
	private System.Windows.Forms.Button Button4;

	//Required by the Windows Form Designer 
    private System.ComponentModel.IContainer components;

    //NOTE: The following procedure is required by the Windows Form Designer 
    //It can be modified using the Windows Form Designer.   
    //Do not modify it using the code editor.
    private void InitializeComponent()
		this.FlowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
		this.Button1 = new System.Windows.Forms.Button();
		this.Button2 = new System.Windows.Forms.Button();
		this.Button3 = new System.Windows.Forms.Button();
		this.Button4 = new System.Windows.Forms.Button();
		this.wrapContentsCheckBox = new System.Windows.Forms.CheckBox();
		this.flowTopDownBtn = new System.Windows.Forms.RadioButton();
		this.flowBottomUpBtn = new System.Windows.Forms.RadioButton();
		this.flowLeftToRight = new System.Windows.Forms.RadioButton();
		this.flowRightToLeftBtn = new System.Windows.Forms.RadioButton();
// FlowLayoutPanel1 
		this.FlowLayoutPanel1.Location = new System.Drawing.Point(47, 55);
		this.FlowLayoutPanel1.Name = "FlowLayoutPanel1";
		this.FlowLayoutPanel1.TabIndex = 0;
// Button1 
		this.Button1.Location = new System.Drawing.Point(3, 3);
		this.Button1.Name = "Button1";
		this.Button1.TabIndex = 0;
		this.Button1.Text = "Button1";
// Button2 
		this.Button2.Location = new System.Drawing.Point(84, 3);
		this.Button2.Name = "Button2";
		this.Button2.TabIndex = 1;
		this.Button2.Text = "Button2";
// Button3 
		this.Button3.Location = new System.Drawing.Point(3, 32);
		this.Button3.Name = "Button3";
		this.Button3.TabIndex = 2;
		this.Button3.Text = "Button3";
// Button4 
		this.Button4.Location = new System.Drawing.Point(84, 32);
		this.Button4.Name = "Button4";
		this.Button4.TabIndex = 3;
		this.Button4.Text = "Button4";
// wrapContentsCheckBox 
		this.wrapContentsCheckBox.Location = new System.Drawing.Point(46, 162);
		this.wrapContentsCheckBox.Name = "wrapContentsCheckBox";
		this.wrapContentsCheckBox.TabIndex = 1;
		this.wrapContentsCheckBox.Text = "Wrap Contents";
		this.wrapContentsCheckBox.CheckedChanged += new System.EventHandler(this.wrapContentsCheckBox_CheckedChanged);
// flowTopDownBtn 
		this.flowTopDownBtn.Location = new System.Drawing.Point(45, 193);
		this.flowTopDownBtn.Name = "flowTopDownBtn";
		this.flowTopDownBtn.TabIndex = 2;
		this.flowTopDownBtn.Text = "Flow TopDown";
		this.flowTopDownBtn.CheckedChanged += new System.EventHandler(this.flowTopDownBtn_CheckedChanged);
// flowBottomUpBtn 
		this.flowBottomUpBtn.Location = new System.Drawing.Point(44, 224);
		this.flowBottomUpBtn.Name = "flowBottomUpBtn";
		this.flowBottomUpBtn.TabIndex = 3;
		this.flowBottomUpBtn.Text = "Flow BottomUp";
		this.flowBottomUpBtn.CheckedChanged += new System.EventHandler(this.flowBottomUpBtn_CheckedChanged);
// flowLeftToRight 
		this.flowLeftToRight.Location = new System.Drawing.Point(156, 193);
		this.flowLeftToRight.Name = "flowLeftToRight";
		this.flowLeftToRight.TabIndex = 4;
		this.flowLeftToRight.Text = "Flow LeftToRight";
		this.flowLeftToRight.CheckedChanged += new System.EventHandler(this.flowLeftToRight_CheckedChanged);
// flowRightToLeftBtn 
		this.flowRightToLeftBtn.Location = new System.Drawing.Point(155, 224);
		this.flowRightToLeftBtn.Name = "flowRightToLeftBtn";
		this.flowRightToLeftBtn.TabIndex = 5;
		this.flowRightToLeftBtn.Text = "Flow RightToLeft";
		this.flowRightToLeftBtn.CheckedChanged += new System.EventHandler(this.flowRightToLeftBtn_CheckedChanged);
// Form1 
		this.ClientSize = new System.Drawing.Size(292, 266);
		this.Name = "Form1";
		this.Text = "Form1";


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0