Getting Started with WinForms Border Layout

18 Nov 20183 minutes to read

This section explains how to add the WinForms Border Layout control in a Windows Forms application and overview its basic functionalities.

Assembly deployment

Refer to the control dependencies section to get the list of assemblies or NuGet packages that need to be added as a reference to use the control in any application.

Find more details about installing the NuGet packages in a Windows Forms application in the following link: How to install NuGet packages.

Creating the project

Create a new Windows Forms project in Visual Studio to display the WinForms Border Layout with basic functionalities.

Adding the WinForms Border Layout control through designer

The WinForms Border Layout control can be added to an application by dragging it from the toolbox to designer view. The following required assembly reference will be added automatically.

  • Syncfusion.Shared.Base.dll

WinForms BorderLayout being dragged from the Visual Studio toolbox onto the designer

To add the form as a container control of the WinForms Border Layout, click Yes in the pop up. The form is automatically assigned as the container control before the WinForms Border Layout is added.

Confirmation dialog asking whether the form should be used as the container control of BorderLayout

Adding layout components

The child controls can be added to the layout by dragging them from the toolbox to the designer view.

Three child controls placed inside the WinForms BorderLayout container

Adding the WinForms Border Layout control through code

The WinForms Border Layout control can be created programmatically as described below.

Step 1: Create a C# or VB.NET application through Visual Studio.

Step 2: Add the following required assembly references to the project

Syncfusion.Shared.Base.dll

Step 3: Include the required namespace.

using Syncfusion.Windows.Forms.Tools;
Imports Syncfusion.Windows.Forms.Tools

Step 4: Create an instance of the WinForms Border Layout control, and set the container control as the form.

BorderLayout borderLayout1 = new BorderLayout();

this.borderLayout1.ContainerControl = this;
Dim borderLayout1 As BorderLayout = New BorderLayout()

Me.borderLayout1.ContainerControl = Me

Adding layout components

The child controls can be added to the layout by simply adding them to the form, since the form is its container control.

ButtonAdv buttonAdv1 = new ButtonAdv();
ButtonAdv buttonAdv2 = new ButtonAdv();
ButtonAdv buttonAdv3 = new ButtonAdv();

this.buttonAdv1.Text = "buttonAdv1";
this.buttonAdv2.Text = "buttonAdv2";
this.buttonAdv3.Text = "buttonAdv3";

this.buttonAdv1.Dock = System.Windows.Forms.DockStyle.Top;
this.buttonAdv2.Dock = System.Windows.Forms.DockStyle.Left;
this.buttonAdv3.Dock = System.Windows.Forms.DockStyle.Right;

this.Controls.Add(this.buttonAdv1);
this.Controls.Add(this.buttonAdv2);
this.Controls.Add(this.buttonAdv3);
Dim buttonAdv1 As ButtonAdv = New ButtonAdv()
Dim buttonAdv2 As ButtonAdv = New ButtonAdv()
Dim buttonAdv3 As ButtonAdv = New ButtonAdv()

Me.buttonAdv1.Text = "buttonAdv1"
Me.buttonAdv2.Text = "buttonAdv2"
Me.buttonAdv3.Text = "buttonAdv3"

Me.buttonAdv1.Dock = System.Windows.Forms.DockStyle.Top
Me.buttonAdv2.Dock = System.Windows.Forms.DockStyle.Left
Me.buttonAdv3.Dock = System.Windows.Forms.DockStyle.Right

Me.Controls.Add(Me.buttonAdv1)
Me.Controls.Add(Me.buttonAdv2)
Me.Controls.Add(Me.buttonAdv3)

WinForms BorderLayout child controls laid out along the top, left, and right borders after applying dock styles