Exportieren (0) Drucken
Alle erweitern

FlowLayoutPanel-Klasse

Aktualisiert: November 2007

Stellt einen Bereich dar, in dem der Inhalt dynamisch horizontal oder vertikal angeordnet wird.

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

[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[DockingAttribute(DockingBehavior.Ask)]
[ComVisibleAttribute(true)]
public class FlowLayoutPanel : Panel, 
	IExtenderProvider
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
/** @attribute DockingAttribute(DockingBehavior.Ask) */
/** @attribute ComVisibleAttribute(true) */
public class FlowLayoutPanel extends Panel implements IExtenderProvider
public class FlowLayoutPanel extends Panel implements IExtenderProvider

Das FlowLayoutPanel-Steuerelement ordnet seinen Inhalt in horizontaler oder vertikaler Flussrichtung an. Der Inhalt kann zeilenweise oder spaltenweise umbrochen werden. Wenn der Inhalt nicht umbrochen wird, kann er auch abgeschnitten werden.

Sie können die Flussrichtung angeben, indem Sie den Wert der FlowDirection-Eigenschaft festlegen. Die Flussrichtung des FlowLayoutPanel-Steuerelements wird in Layouts mit Leserichtung von rechts nach links (RNL) ordnungsgemäß umgekehrt. Ob der Inhalt des FlowLayoutPanel-Steuerelements umbrochen oder abgeschnitten wird, können Sie auch angeben, indem Sie den Wert der WrapContents-Eigenschaft festlegen.

Jedes Windows Forms-Steuerelement, einschließlich anderer Instanzen von FlowLayoutPanel, kann ein untergeordnetes Element des FlowLayoutPanel-Steuerelements sein. Mit dieser Funktion können Sie komplizierte Layouts erstellen, die sich zur Laufzeit an die Dimensionen des Formulars anpassen.

Das Andock- und Verankerungsverhalten untergeordneter Steuerelemente unterscheidet vom Verhalten in anderen Containersteuerelementen. Sowohl das Andocken als auch das Verankern erfolgen relativ zum größten Steuerelement in der Flussrichtung. Weitere Informationen finden Sie unter Gewusst wie: Verankern und Andocken von untergeordneten Steuerelementen in einem FlowLayoutPanel-Steuerelement.

Im folgenden Beispiel wird das Festlegen der FlowDirection-Eigenschaft und der WrapContents-Eigenschaft für ein FlowLayoutPanel-Steuerelement veranschaulicht. Fügen Sie den Code in die Quelldatei Form1 ein. Wenn das Projekt eine Datei mit dem Namen Form1.Designer.cs oder Form1.Designer.vb enthält, entfernen Sie diese Datei aus dem Projekt. Möglicherweise müssen Sie im Projektmappen-Explorer auf die Schaltfläche Alle Dateien anzeigen klicken, um die Designerdatei anzuzeigen.


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 = 
			this.wrapContentsCheckBox.Checked;
    }

    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.
        InitializeComponent();

        //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)
            {
                components.Dispose();
            }
        }
        base.Dispose(disposing);
    }

	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.
    [System.Diagnostics.DebuggerNonUserCode]
    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();
		this.FlowLayoutPanel1.SuspendLayout();
		this.SuspendLayout();
// 
// FlowLayoutPanel1
// 
		this.FlowLayoutPanel1.Controls.Add(this.Button1);
		this.FlowLayoutPanel1.Controls.Add(this.Button2);
		this.FlowLayoutPanel1.Controls.Add(this.Button3);
		this.FlowLayoutPanel1.Controls.Add(this.Button4);
		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.Controls.Add(this.flowRightToLeftBtn);
		this.Controls.Add(this.flowLeftToRight);
		this.Controls.Add(this.flowBottomUpBtn);
		this.Controls.Add(this.flowTopDownBtn);
		this.Controls.Add(this.wrapContentsCheckBox);
		this.Controls.Add(this.FlowLayoutPanel1);
		this.Name = "Form1";
		this.Text = "Form1";
		this.FlowLayoutPanel1.ResumeLayout(false);
		this.ResumeLayout(false);
	}

#endregion
}


import System.*;
import System.Windows.Forms.*;

public class Form1 extends System.Windows.Forms.Form
{
    private void wrapContentsCheckBox_CheckedChanged(Object sender, 
        System.EventArgs e)
    {
        this.flowLayoutPanel1.set_WrapContents(this.wrapContentsCheckBox.
            get_Checked());
    } //wrapContentsCheckBox_CheckedChanged

    private void flowTopDownBtn_CheckedChanged(Object sender,
        System.EventArgs e)
    {
        this.flowLayoutPanel1.set_FlowDirection(FlowDirection.TopDown);
    } //flowTopDownBtn_CheckedChanged

    private void flowBottomUpBtn_CheckedChanged(Object sender,
        System.EventArgs e)
    {
        this.flowLayoutPanel1.set_FlowDirection(FlowDirection.BottomUp);
    } //flowBottomUpBtn_CheckedChanged

    private void flowLeftToRight_CheckedChanged(Object sender, 
        System.EventArgs e)
    {
        this.flowLayoutPanel1.set_FlowDirection(FlowDirection.LeftToRight);
    } //flowLeftToRight_CheckedChanged

    private void flowRightToLeftBtn_CheckedChanged(Object sender,
        System.EventArgs e)
    {
        this.flowLayoutPanel1.set_FlowDirection(FlowDirection.RightToLeft);
    } //flowRightToLeftBtn_CheckedChanged

    #region " Windows Form Designer generated code "
    public Form1()
    {
        //This call is required by the Windows Form Designer.
        InitializeComponent();
    } //Form1

    //Add any initialization after the InitializeComponent() call
    //Form overrides dispose to clean up the component list.
    protected void Dispose(boolean disposing)
    {
        if (disposing) {
            if (components != null) {
                components.Dispose();
            }
        }
        super.Dispose(disposing);
    } //Dispose

    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.
    /** @attribute System.Diagnostics.DebuggerNonUserCode()
     */
    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();
        this.flowLayoutPanel1.SuspendLayout();
        this.SuspendLayout();
        // 
        // flowLayoutPanel1
        // 
        this.flowLayoutPanel1.get_Controls().Add(this.button1);
        this.flowLayoutPanel1.get_Controls().Add(this.button2);
        this.flowLayoutPanel1.get_Controls().Add(this.button3);
        this.flowLayoutPanel1.get_Controls().Add(this.button4);
        this.flowLayoutPanel1.set_Location(new System.Drawing.Point(47, 55));
        this.flowLayoutPanel1.set_Name("flowLayoutPanel1");
        this.flowLayoutPanel1.set_TabIndex(0);
        // 
        // button1
        // 
        this.button1.set_Location(new System.Drawing.Point(3, 3));
        this.button1.set_Name("button1");
        this.button1.set_TabIndex(0);
        this.button1.set_Text("button1");
        // 
        // button2
        // 
        this.button2.set_Location(new System.Drawing.Point(84, 3));
        this.button2.set_Name("button2");
        this.button2.set_TabIndex(1);
        this.button2.set_Text("button2");
        // 
        // button3
        // 
        this.button3.set_Location(new System.Drawing.Point(3, 32));
        this.button3.set_Name("button3");
        this.button3.set_TabIndex(2);
        this.button3.set_Text("button3");
        // 
        // button4
        // 
        this.button4.set_Location(new System.Drawing.Point(84, 32));
        this.button4.set_Name("button4");
        this.button4.set_TabIndex(3);
        this.button4.set_Text("button4");
        // 
        // wrapContentsCheckBox
        // 
        this.wrapContentsCheckBox.set_Location(new System.Drawing.Point(46, 162));
        this.wrapContentsCheckBox.set_Name("wrapContentsCheckBox");
        this.wrapContentsCheckBox.set_TabIndex(1);
        this.wrapContentsCheckBox.set_Text("Wrap Contents");
        this.wrapContentsCheckBox.add_CheckedChanged(new System.EventHandler(
            this.wrapContentsCheckBox_CheckedChanged));
        // 
        // flowTopDownBtn
        // 
        this.flowTopDownBtn.set_Location(new System.Drawing.Point(45, 193));
        this.flowTopDownBtn.set_Name("flowTopDownBtn");
        this.flowTopDownBtn.set_TabIndex(2);
        this.flowTopDownBtn.set_Text("Flow TopDown");
        this.flowTopDownBtn.add_CheckedChanged(new System.EventHandler(
            this.flowTopDownBtn_CheckedChanged));
        // 
        // flowBottomUpBtn
        // 
        this.flowBottomUpBtn.set_Location(new System.Drawing.Point(44, 224));
        this.flowBottomUpBtn.set_Name("flowBottomUpBtn");
        this.flowBottomUpBtn.set_TabIndex(3);
        this.flowBottomUpBtn.set_Text("Flow BottomUp");
        this.flowBottomUpBtn.add_CheckedChanged(new System.EventHandler(
            this.flowBottomUpBtn_CheckedChanged));
        // 
        // flowLeftToRight
        // 
        this.flowLeftToRight.set_Location(new System.Drawing.Point(156, 193));
        this.flowLeftToRight.set_Name("flowLeftToRight");
        this.flowLeftToRight.set_TabIndex(4);
        this.flowLeftToRight.set_Text("Flow LeftToRight");
        this.flowLeftToRight.add_CheckedChanged(new System.EventHandler(
            this.flowLeftToRight_CheckedChanged));
        // 
        // flowRightToLeftBtn
        // 
        this.flowRightToLeftBtn.set_Location(new System.Drawing.Point(155, 224));
        this.flowRightToLeftBtn.set_Name("flowRightToLeftBtn");
        this.flowRightToLeftBtn.set_TabIndex(5);
        this.flowRightToLeftBtn.set_Text("Flow RightToLeft");
        this.flowRightToLeftBtn.add_CheckedChanged(new System.EventHandler(
            this.flowRightToLeftBtn_CheckedChanged));
        // 
        // Form1
        // 
        this.set_ClientSize(new System.Drawing.Size(292, 266));
        this.get_Controls().Add(this.flowRightToLeftBtn);
        this.get_Controls().Add(this.flowLeftToRight);
        this.get_Controls().Add(this.flowBottomUpBtn);
        this.get_Controls().Add(this.flowTopDownBtn);
        this.get_Controls().Add(this.wrapContentsCheckBox);
        this.get_Controls().Add(this.flowLayoutPanel1);
        this.set_Name("Form1");
        this.set_Text("Form1");
        this.flowLayoutPanel1.ResumeLayout(false);
        this.ResumeLayout(false);
    } //InitializeComponent
    #endregion
} //Form1 


Alle öffentlichen static (Shared in Visual Basic)-Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

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

.NET Framework und .NET Compact Framework unterstützen nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.

.NET Framework

Unterstützt in: 3.5, 3.0, 2.0

Community-Beiträge

HINZUFÜGEN
Anzeigen:
© 2015 Microsoft