Extend RadspinEditor control to accept + sign for positive numbers

2 posts, 0 answers
  1. aravind rajagopal
    aravind rajagopal avatar
    1 posts
    Member since:
    Aug 2009

    Posted 20 Feb 2013 Link to this post


    I was creating an application for Opticals. They want increase/decrease the power details using radspin editor.
    And they want to see the + sign for positive numbers like +1.25  (like Negative sign is showing for negative  numbers).

    How can I extend the radspinEditor to achive this result.

    Aravind Rajgopal
  2. Peter
    Peter avatar
    1148 posts

    Posted 25 Feb 2013 Link to this post

    Hi Aravind,

    Thank you for writing.

    The RadSpinEditor does not support formatting in this way. 
    However, you can try to work-around with adding a '+' sign in the TextChanged event. For example:
    radSpinEditor1.SpinElement.TextBoxItem.TextChanged += new EventHandler(TextBoxControl_TextChanged);
    bool internalChange;
    void TextBoxControl_TextChanged(object sender, EventArgs e)
        if (internalChange) return;
        internalChange = true;
        RadTextBoxItem textBox = (RadTextBoxItem)sender;
        if (!textBox.Text.Contains("-"))
            int selection = textBox.SelectionStart;
            textBox.Text = textBox.Text.Replace("+", "");
            textBox.Text = "+" + textBox.Text;
            if (selection == 0)
                selection = 1;
            textBox.SelectionStart = selection;
            textBox.Text = textBox.Text.Replace("+", "");
        internalChange = false;

    Please, keep in mind that I cannot guarantee that everything will work as expected in all possible cases when using this work around.

    I hope this helps.

    Kind regards,
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Back to Top