Getting Started with WinForms Percent TextBox

18 Nov 20183 minutes to read

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

Create a simple application with WinForms Percent TextBox

You can create a Windows Forms application with WinForms Percent TextBox using the following steps.

Create a project

Create a new Windows Forms project in Visual Studio to display the WinForms Percent TextBox control.

Add control through designer

The WinForms Percent TextBox control can be added to an application by dragging it from the toolbox to a designer view. The Syncfusion.Shared.Base assembly reference will be added automatically:

WinForms PercentTextBox control added through the Visual Studio designer

Add control manually in code

To add the control manually in C# or VB, follow the given steps:

  1. Add the Syncfusion.Shared.Base assembly reference to the project.
  2. Include the Syncfusion.Windows.Forms.Tools namespace.

​

using Syncfusion.Windows.Forms.Tools;
Imports Syncfusion.Windows.Forms.Tools
  1. Create a WinForms Percent TextBox instance, and add it to the window.

​

PercentTextBox percentTextBox1 = new PercentTextBox();
   this.Controls.Add(percentTextBox1);
Dim percentTextBox1 As PercentTextBox = New PercentTextBox()
   Me.Controls.Add(percentTextBox1)

WinForms PercentTextBox control added programmatically

Maximum and minimum value constraints

You can set the maximum and minimum percentage values using the MaxValue and MinValue properties of WinForms Percent TextBox.

this.percentTextBox1.MaxValue = 6;
this.percentTextBox1.MinValue = -6;
Me.percentTextBox1.MaxValue = 6
Me.percentTextBox1.MinValue = -6

Change number format

You can customize the number format using the PercentDecimalDigits, PercentDecimalSeparator, PercentGroupSeparator, and PercentGroupSizes properties of WinForms Percent TextBox.

this.percentTextBox1.PercentValue = 12.873;
this.percentTextBox1.PercentDecimalDigits = 3;
this.percentTextBox1.PercentDecimalSeparator = ".";
this.percentTextBox1.PercentGroupSeparator = ",";
this.percentTextBox1.PercentGroupSizes = new int[] { 2 };
Me.percentTextBox1.PercentValue = 12.873
Me.percentTextBox1.PercentDecimalDigits = 3
Me.percentTextBox1.PercentDecimalSeparator = "."
Me.percentTextBox1.PercentGroupSeparator = ","
Me.percentTextBox1.PercentGroupSizes = New Integer() { 2 }

WinForms PercentTextBox with a custom number format applied