SpinEditor used for minutes field

2 posts, 0 answers
  1. Chris
    Chris avatar
    2 posts
    Member since:
    Aug 2012

    Posted 12 Nov 2012 Link to this post

    I've got a problem where a client wants to use a SpinEditor for their hours and minutes fields. The hours field works fine however I'm not able to display the minutes properly for anything below 10 (ie 12:01 appears in the editor without the leading zero, 12:1).  Hopefully, there is something I'm simply over looking . Any help is greatly appriciated.


  2. Peter
    Peter avatar
    1148 posts

    Posted 14 Nov 2012 Link to this post

    Hi Chris,

    Thank you for writing.

    You can customize RadSpinEditor to show a leading zero. Consider the following sample:
    radSpinEditor2.SpinElement.TextBoxItem.Text = "0" + radSpinEditor2.SpinElement.TextBoxItem.Text;
    radSpinEditor2.SpinElement.TextBoxItem.TextChanged += new EventHandler(radSpinEditor2_TextChanged);
    private void radSpinEditor2_TextChanged(object sender, EventArgs e)
        RadTextBoxItem textBox = ((RadTextBoxItem)sender);
        if ((!textBox.Text.StartsWith("0") && textBox.Text.Length == 1) || textBox.Text=="0")
            textBox.Text = "0" + textBox.Text;

    I hope this helps.

    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  3. DevCraft R3 2016 release webinar banner
Back to Top