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

RadNumericUpDown lets you type beyond its maximum value

6 Answers 480 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Sanket Singhvi
Top achievements
Rank 1
Sanket Singhvi asked on 20 Nov 2010, 12:43 AM
Hi,

I set the maximum on RadNumericUpDown but using keyboard I can type beyond maximum value.

Regards
Sanket

6 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 23 Nov 2010, 11:41 AM
Hello Sanket,

Thank you for contacting us.

This is by design. The Maximum property is not meant to restrict the user's input when typing in the TextBox of the NumericUpDown only when using the arrows.

Hope this information helps. If you have further questions please let us know.

All the best,
Konstantina
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Tim
Top achievements
Rank 1
answered on 26 Nov 2010, 05:47 PM
OK, so how do you restrict entry? The MS textbox has a MaxLength property. What is the equivalent for the RadNumericUpDown?
0
Konstantina
Telerik team
answered on 29 Nov 2010, 01:03 PM
Hi Tim,

As a work-around I can suggest you to hook to the PreviewTextInput event and check the length of the typed-in text and if longer mark the event handled, for example:
private void RadNumericUpDown_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
    var num = sender as RadNumericUpDown;
    if (num.ContentText.Length > 3)
    {
        e.Handled = true;
    }
}

Hope this helps. If you have further questions please let us know.

Kind regards,
Konstantina
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
maks
Top achievements
Rank 1
answered on 14 Mar 2014, 09:22 AM
<telerik:RadNumericUpDown>
                                <telerik:RadNumericUpDown.Resources>
                                    <Style TargetType="{x:Type TextBox}">
                                        <Setter Property="MaxLength" Value="2" /> 
                                    </Style>
                                </telerik:RadNumericUpDown.Resources>
                            </telerik:RadNumericUpDown>
0
Prashanth
Top achievements
Rank 1
answered on 07 Mar 2018, 01:18 PM

Hi Konstantina,

I restricted the length of text as u said but I have one more requirement i.e I don't want to allow greater than the particular number when user typing in the TextBox of the RadNumericUpDown.

Eg: NumericUpDown textbox will allow only less than the '300'

Please suggest if any approach to solve.

 

Thanks and Regards

M.Prashanth Reddy

 

 

 

0
Martin
Telerik team
answered on 12 Mar 2018, 09:36 AM
Hi Prashanth,

To achieve the desired behavior you can parse the ContentText property to double and if the value is greater than 300 to handle the preview event.

I hope that this helps. If you have further questions please let us know.


Regards,
Martin Vatev
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.
Tags
NumericUpDown
Asked by
Sanket Singhvi
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Tim
Top achievements
Rank 1
maks
Top achievements
Rank 1
Prashanth
Top achievements
Rank 1
Martin
Telerik team
Share this question
or