Getting Started with Windows Forms TextBox

5 Jun 20233 minutes to read

This section briefly describes how to create a new Windows Forms project in Visual Studio and add TextBoxExt with its basic functionalities.

Assembly deployment

Refer to the control dependencies section to get the list of assemblies or the details of NuGet package that needs to be added as reference to use the control in any application.

Refer to this documentation to find more details about installing nuget packages in a Windows Forms application.

Creating application with TextBoxExt

In this walk through, users will create new WinForms application that contains TextBoxExt control.

Creating the project

Create new Windows Forms Project in Visual Studio to display TextBoxExt with different text settings.

Adding the TextBoxExt control via designer

The TextBoxExt control can be added to the application by dragging it from the toolbox and dropping it in designer. The required assembly references will be added automatically.

Drag and drop TextBoxExt from toolbox in WindowsForms application

Adding the TextBoxExt control via code

In order to add control manually, do the below steps,

  1. Add the following assembly reference to the project.

    • Syncfusion.Shared.Base
  2. Include the required namespace.

    using Syncfusion.Windows.Forms.Tools;
    Imports Syncfusion.Windows.Forms.Tools
  3. Create the TextBoxExt control instance, and add it to the form.

    TextBoxExt textBoxExt1 = new TextBoxExt();
    textBoxExt1.Text = "textboxext1";
    this.Controls.Add(textBoxExt1);
    Dim textBoxExt1 As New TextBoxExt()
    textBoxExt1.Text = "textboxext1"
    Me.Controls.Add(textBoxExt1)

Show the text in WindowsForms TextBox

Size

The size to the TextBoxExt control can be applied using the following properties:

textBoxExt1.MinimumSize = new System.Drawing.Size(267, 104);
textBoxExt1.MaximumSize = new System.Drawing.Size(267, 104);
textBoxExt1.MaximumSize = New System.Drawing.Size(267, 104)
textBoxExt1.MinimumSize = New System.Drawing.Size(267, 104)

Windows Forms TextBoxExt showing size of the control

Multiline

The TextBoxExt control can be customized to display multiline text using the following properties:

  • Multiline - Spans the text of the edit control to more than one line.
  • WordWrap - Indicates whether the lines are automatically word-wrapped for the multiline edit controls.
  • ScrollBars - Enables scrollbars when the text overflows the size of the text box. The available options are horizontal, vertical, both, and none.
textBoxExt1.Multiline = true;
textBoxExt1.WordWrap = true;
textBoxExt1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
textBoxExt1.Multiline = True
textBoxExt1.WordWrap = True
textBoxExt1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical

Windows Forms TextBoxExt shows mulitiline text