Formating the CalculatorDropDown

3 posts, 0 answers
  1. Hardy
    Hardy avatar
    14 posts
    Member since:
    Mar 2012

    Posted 20 Jul 2015 Link to this post



    I like to assign a FormatString to the CalculatorDropDown like Columns.FormatString in GridView-Control.

    Example: A value 2.17 should be formated 2.17 m² to display the value in squaremeters.

    Is there any property to set or any other solution to format the value in the Calculator-Control?




  2. Dess
    Dess avatar
    2166 posts

    Posted 20 Jul 2015 Link to this post

    Hello Hardy,

    Thank you for writing.

    RadCalculatorEditorContentElement is a derivative of the RadTextBoxElement which hosts the standard MS TextBox. It does not offer formatting out of the box. Additionally, the RadCalculatorDropDownElement.Value property accepts decimal values. Hence, in order to force some custom format to the calculator, you can use a RadMaskedEditBox and add the arrow button that shows the calculator popup. Here is a sample implementation:
    RadCalculatorDropDownElement calculatorElement = new RadCalculatorDropDownElement();
    public Form1()
        this.radMaskedEditBox1.MaskType = MaskType.Numeric;
        this.radMaskedEditBox1.Mask = "C";
        CultureInfo culture = System.Threading.Thread.CurrentThread.CurrentCulture.Clone() as CultureInfo;
        culture.NumberFormat.CurrencyPositivePattern = 1;
        culture.NumberFormat.CurrencyNegativePattern = 5;
        culture.NumberFormat.CurrencySymbol = "m²";
        this.radMaskedEditBox1.Culture = culture;
        calculatorElement.PopupClosed += calculatorElement_PopupClosed;
        calculatorElement.BorderPrimitive.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
        calculatorElement.EditorContentElement.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
        StackLayoutElement stackPanel = new StackLayoutElement();
        stackPanel.Orientation = Orientation.Horizontal;
        stackPanel.Margin = new Padding(1, 0, 1, 0);
        RadTextBoxItem tbItem = this.radMaskedEditBox1.MaskedEditBoxElement.TextBoxItem;
        DockLayoutPanel dockPanel = new DockLayoutPanel();
        DockLayoutPanel.SetDock(tbItem, Telerik.WinControls.Layouts.Dock.Left);
        DockLayoutPanel.SetDock(stackPanel, Telerik.WinControls.Layouts.Dock.Right);
    private void calculatorElement_PopupClosed(object sender, RadPopupClosedEventArgs args)
        this.radMaskedEditBox1.Value = calculatorElement.Value;

    Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify it on a way which suits your requirement best.

    I hope this information helps. Should you have further questions, I would be glad to help.

  3. Hardy
    Hardy avatar
    14 posts
    Member since:
    Mar 2012

    Posted 20 Jul 2015 in reply to Dess Link to this post


    that's a good idea.

    I will embed your snippet into an usercontrol.


    Thanks a lot


Back to Top