How to Customize the Calculator Display Text Area to Use NumberGroupSeparator

3 Sep 20201 minute to read

The Calculator control by default does not allow the use of NumberGroupSeparator like in DoubleTextBox.

Number group

So to achieve this we need to derive the Calculator control and override the CreateCalculatorDisplayBox() method.

private CalculatorAdv calculatorControl1;
this.calculatorControl1 = new CalculatorAdv();
public class CalculatorAdv : Syncfusion.Windows.Forms.Tools.CalculatorControl
{
    public CalculatorAdv()
    {
    }
    protected override void CreateCalculatorDisplayBox()
    {
        Syncfusion.Windows.Forms.Tools.DoubleTextBox dtb = new Syncfusion.Windows.Forms.Tools.DoubleTextBox();
        dtb.NumberGroupSeparator = ",";
        this.textCalculatorBox = dtb; //Changing the TextBox to DoubleTextBox
    }
}
Private calculatorControl1 As CalculatorAdv
Me.calculatorControl1 = New CalculatorAdv() 
Public Class CalculatorAdv
Inherits Syncfusion.Windows.Forms.Tools.CalculatorControl
Public Sub New()
End Sub
Protected Overloads Overrides Sub CreateCalculatorDisplayBox()
Dim dtb As New Syncfusion.Windows.Forms.Tools.DoubleTextBox()
dtb.NumberGroupSeparator = ","
Me.textCalculatorBox = dtb
'Changing the TextBox to DoubleTextBox 
End Sub
End Class

Number group separator