This is a migrated thread and some comments may be shown as answers.
Leading zeros in RadNumericUpDown
1 Answer 14 Views
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 1
Markus asked on 14 Jun 2018, 10:41 AM

Hi,

I would like to use the RadNumericUpDown but would have to make all numbers double digits.

So with numbers from 1 to 99 there should 01, 02, 03 ... appear.

Is there a function for this?

 

Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Accepted
Kalin
Telerik team
answered on 19 Jun 2018, 08:24 AM
Hello Markus,

What I can suggest you would be to inherit from RadNumericUpDown and override the FormatEdit and FormatDisplay method. They are responsible for formatting the text when in edit and in display mode. Please try the following snippets:

public override string FormatDisplay()
{
    if (this.Value.HasValue)
    {
        return this.Value.Value.ToString("00");                
    }
 
    return base.FormatDisplay();
}
 
public override string FormatEdit()
{
    if (this.Value.HasValue)
    {
        return this.Value.Value.ToString("00");
    }
 
    return base.FormatEdit();
}

Hope this helps. Please let me know if you have any other questions or concerns.

Regards,
Kalin
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Asked by
Markus
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Share this question
or