This is a migrated thread and some comments may be shown as answers.

SpinEditor used for minutes field

1 Answer 54 Views
SpinEditor
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 12 Nov 2012, 02:31 PM
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.

Thanks,

Chris

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 14 Nov 2012, 12:21 PM
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.

Greetings,
Peter
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
SpinEditor
Asked by
Chris
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or