Getting Started with Windows Forms ButtonEdit

13 Oct 20226 minutes to read

This section briefly describes how to create a new Windows Forms project in Visual Studio and add ButtonEdit with it’s basic functionalities.

Assembly deployment

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

Check here to find more details on how to install nuget packages in Windows Forms application.

Creating Application with ButtonEdit

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

Creating the Project

Create new Windows Forms Project in Visual Studio to display ButtonEdit control.

Adding a ButtonEdit control through designer

Step 1: Create a new Windows Forms application in Visual Studio. Drag and drop the ButtonEdit from toolbox in Form designer window. The dependent assemblies will be added automatically.

ButtonEdit control from toolbox

Step 2: Set the desired properties for ButtonEdit control using the “Properties” dialog window.

Showing properties pane customizing ButtonEdit control

Step 3: You can add the child buttons for the ButtonEdit using ButtonEditChildButton Collection Editor” dialog box.

Showing Button child buttons collection editor

Adding ButtonEdit control through Code

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

  1. Add the required assembly references to the project.

  2. Create the ButtonEdit control instance and add it to the Form.

    using Syncfusion.Windows.Forms.Tools;
    Imports Syncfusion.Windows.Forms.Tools
    public Form1()
    {            
        InitializeComponent();
        ButtonEdit buttonEdit = new ButtonEdit();
        buttonEdit.Location = new System.Drawing.Point(367, 135);
        buttonEdit.Name = "buttonEdit1";
        buttonEdit.Text = buttonEdit.Name;
        buttonEdit.Size = new System.Drawing.Size(121, 21);
        this.Controls.Add(buttonEdit);
    }
    Public Sub New()
       
        InitializeComponent()
        Dim ButtonEdit As buttonEdit = New ButtonEdit()
        buttonEdit.Location = New System.Drawing.Point(367, 135)
        buttonEdit.Name = "buttonEdit1"
        buttonEdit.Text = buttonEdit.Name
        buttonEdit.Size = New System.Drawing.Size(121, 21)
        Me.Controls.Add(buttonEdit)
           
    End Sub

ButtonEdit added by code

Embed the TextBox and ChildButtons in ButtonEdit control

ButtonEdit control is a combination of textbox and buttons. It contains TextBox property to embed the instance of the textbox control. Also, we can set different types of textbox such as PercentTextBox, IntegerTextBox, etc. Meanwhile we can add child buttons in Buttons collection.

public Form1()
{
            
    InitializeComponent();
    TextBoxExt textBoxExt1;
    ButtonEditChildButton ButtonEditChildButton1;
    ButtonEditChildButton ButtonEditChildButton2;
    ButtonEditChildButton ButtonEditChildButton3;
    ButtonEdit buttonEdit = new ButtonEdit();
    buttonEdit.Location = new System.Drawing.Point(145, 135);
    buttonEdit.Name = "ButtonEdit1";
    buttonEdit.Size = new System.Drawing.Size(121, 21);
    textBoxExt1 = new TextBoxExt();
    ButtonEditChildButton1 = new ButtonEditChildButton();
    ButtonEditChildButton2 = new ButtonEditChildButton();
    ButtonEditChildButton3 = new ButtonEditChildButton();

    //Embedding text in TextBox
    buttonEdit.TextBox = textBoxExt1;
    buttonEdit.Controls.Add(textBoxExt1);

    //Aligning the child button
    ButtonEditChildButton1.ButtonAlign = ButtonAlignment.Left;

    //Setting text for child buttons
    ButtonEditChildButton1.Text = "L";
    ButtonEditChildButton2.Text = "R";
    ButtonEditChildButton3.Text = "E";

    //Adding child buttons 
    buttonEdit.Buttons.Add(ButtonEditChildButton1);
    buttonEdit.Buttons.Add(ButtonEditChildButton2);
    buttonEdit.Buttons.Add(ButtonEditChildButton3);
    this.Controls.Add(buttonEdit);

}
Public Sub New()

    InitializeComponent()
    Dim textBoxExt1 As TextBoxExt
    Dim ButtonEditChildButton1 As ButtonEditChildButton
    Dim ButtonEditChildButton2 As ButtonEditChildButton
    Dim ButtonEditChildButton3 As ButtonEditChildButton
    Dim ButtonEdit As buttonEdit = New ButtonEdit()
    buttonEdit.Location = New System.Drawing.Point(367, 135)
    buttonEdit.Name = "ButtonEdit1"
    buttonEdit.Size = New System.Drawing.Size(121, 21)
    textBoxExt1 = New TextBoxExt()
    ButtonEditChildButton1 = New ButtonEditChildButton()
    ButtonEditChildButton2 = New ButtonEditChildButton()
    ButtonEditChildButton3 = New ButtonEditChildButton()

    'Embedding text in TextBox
    buttonEdit.TextBox = textBoxExt1
    buttonEdit.Controls.Add(Me.textBoxExt1)
    ButtonEditChildButton1.ButtonAlign = ButtonAlignment.Left

    'Setting text for child buttons
    ButtonEditChildButton1.Text = "L"
    ButtonEditChildButton2.Text = "R"
    ButtonEditChildButton3.Text = "E"

    'Adding child buttons 
    buttonEdit.Buttons.Add(ButtonEditChildButton1)
    buttonEdit.Buttons.Add(ButtonEditChildButton2)
    buttonEdit.Buttons.Add(ButtonEditChildButton3)
    Me.Controls.Add(buttonEdit)

End Sub

ButtonEdit with Text and child buttons