Getting Started with Windows Forms AutoLabel
18 Nov 20188 minutes to read
This section explains how to get started with the Windows Forms AutoLabel control and its basic features.
Assembly Deployment
Refer to the Control Dependencies section for the list of assemblies and NuGet packages required to use the AutoLabel control.
Refer to NuGet Packages to learn how to install NuGet packages in a Windows Forms application.
To install the required NuGet package using the NuGet Package Manager Console, run the following command:
Install-Package Syncfusion.Shared.BaseAdding AutoLabel via Designer
-
Create a new Windows Forms application in Visual Studio.
-
Drag the
AutoLabelcontrol from the Toolbox and drop it onto the Windows Form designer. The following dependent assembly is added automatically:- Syncfusion.Shared.Base

-
Configure the desired properties of the
AutoLabelcontrol using the Properties window.
Adding AutoLabel via Code
The following steps describe how to create an AutoLabel control programmatically:
-
Create a C# or VB.NET Windows Forms application in Visual Studio.
-
Add the following assembly reference to the project:
- Syncfusion.Shared.Base
-
Include the required namespace.
using System.Drawing; using System.Windows.Forms; using Syncfusion.Windows.Forms.Tools;Imports System.Drawing Imports System.Windows.Forms Imports Syncfusion.Windows.Forms.Tools -
Create an instance of the AutoLabel control, configure its properties, and add it to the form.
public partial class Form1 : Form { private Syncfusion.Windows.Forms.Tools.AutoLabel autoLabel1; public Form1() { InitializeComponent(); this.autoLabel1 = new Syncfusion.Windows.Forms.Tools.AutoLabel(); this.autoLabel1.Text = "autoLabel1"; this.autoLabel1.BackColor = Color.DarkGray; this.autoLabel1.ForeColor = Color.DarkBlue; this.autoLabel1.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0))); this.autoLabel1.TextAlign = ContentAlignment.MiddleCenter; this.Controls.Add(this.autoLabel1); } }Public Partial Class Form1 Inherits Form Private autoLabel1 As Syncfusion.Windows.Forms.Tools.AutoLabel Public Sub New() InitializeComponent() Me.autoLabel1 = New Syncfusion.Windows.Forms.Tools.AutoLabel() Me.autoLabel1.Text = "autoLabel1" Me.autoLabel1.BackColor = Color.DarkGray Me.autoLabel1.ForeColor = Color.DarkBlue Me.autoLabel1.Font = New Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold, GraphicsUnit.Point, CByte((0))) Me.autoLabel1.TextAlign = ContentAlignment.MiddleCenter Me.Controls.Add(Me.autoLabel1) End Sub End Class
Labeling a Control
-
Add a control to the form, such as TextBoxExt.
-
Select the AutoLabel control, and in the Properties window, set the
LabeledControlproperty to theTextBoxExtcontrol. The AutoLabel control is then automatically positioned relative to the labeled control.this.autoLabel1.LabeledControl = this.textBoxExt1;Me.autoLabel1.LabeledControl = Me.textBoxExt1

Spacing
The space between the AutoLabel control and its associated control can be customized using the available spacing properties. When relative positioning is used, you can specify the gap between the label and the associated control.
| AutoLabel Properties | Description |
|---|---|
| DX | The effective horizontal distance between the left of the AutoLabel and its labeled control. |
| DY | The effective vertical distance between the top of the AutoLabel and its labeled control. |
| Gap | Specifies the horizontal and vertical gap to use when computing the relative position. |
this.autoLabel1.DX = -70;
this.autoLabel1.DY = 3;
this.autoLabel1.Gap = 10;Me.autoLabel1.DX = -70
Me.autoLabel1.DY = 3
Me.autoLabel1.Gap = 10
Position
The AutoLabel control can be positioned relative to the top, left, bottom, or right side of the labeled control.
| AutoLabel Property | Description |
|---|---|
Position |
Specifies the relative position of the AutoLabel control with respect to the labeled control. The available values are Left, Top, Right, Bottom, and Custom. |
When the Position property is set to Custom, you can drag the label to the required position by using the mouse.
this.autoLabel1.Position = Syncfusion.Windows.Forms.Tools.AutoLabelPosition.Left;Me.autoLabel1.Position = Syncfusion.Windows.Forms.Tools.AutoLabelPosition.Left
Size
The AutoLabel control can be resized using the AutoSize property. It automatically resizes the control based on the size of its content and font.
Note: This property applies only to label controls that do not wrap text.
this.autoLabel1.AutoSize = true;Me.autoLabel1.AutoSize = TrueApplying Themes Using SkinManager
You can apply a theme to the AutoLabel control by calling the SkinManager.SetVisualStyle method and specifying a VisualTheme value.
SkinManager.SetVisualStyle(this.autoLabel1, VisualTheme.Office2016Colorful);SkinManager.SetVisualStyle(Me.autoLabel1, VisualTheme.Office2016Colorful)
This control supports only Office2016Colorful, Office2016Black, Office2016DarkGray, and Office2016White styles using SkinManager.