3 Answers, 1 is accepted
0
Hello Patrick,
The desired by you functionality is not supported by RadNumericUpDown with its current implementation.
What we could suggest you is to consider using RadMaskedNumericInput - it places the sign as expected while typing a number. So, when "55" is entered and after that "-" the input will be formatted as expected.
Hope this helps.
Regards,
Nasko
Telerik by Progress
The desired by you functionality is not supported by RadNumericUpDown with its current implementation.
What we could suggest you is to consider using RadMaskedNumericInput - it places the sign as expected while typing a number. So, when "55" is entered and after that "-" the input will be formatted as expected.
Hope this helps.
Regards,
Nasko
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
answered on 04 Oct 2016, 05:06 AM
Hello Nasko,
I've just tried the RadNumericUpDown control, but I have problems with it.
The XAML code I'm using is the following:
<
tk:RadMaskedNumericInput
Value
=
"-12345.67"
FormatString
=
"#,###.00"
IsClearButtonVisible
=
"False"
Mask
=
""
SelectionOnFocus
=
"DefaultSelectAll"
SpinMode
=
"None"
maskedInput:MaskedInputExtensions.AllowMinusOnNullValue
=
"True"
/>
If the control contains already a negative value (say "-1"), I enter it with a tab (the text is selected) and type "-2", the control displays "2".
If it contains "1" at the beginning, doing the same thing shows "-2".
This is completely counter-intuitive and leads to errors when entering values: if the old and new value are negative, I must enter a "-", but only after the first digit; if the old value is positive and the new one is negative, I can enter a "-" anywhere; if the new value is positive, never enter the "-".
Is it a bug in the control or something wrong with with properties?
0
Hello Patrick,
The minus sign on the keyboard toggles the value from negative to positive and vice versa, regarding the caret position. If you want to clear the mask when its value is select all and the minus key is pressed you can override the HandleSubtractkey method of RadMaskedNumericInput.
We have SDK example in our GitHub repository showing the mentioned above approach. Give this project a try and let us know if it works for you.
Regards,
Dinko
Telerik by Progress
The minus sign on the keyboard toggles the value from negative to positive and vice versa, regarding the caret position. If you want to clear the mask when its value is select all and the minus key is pressed you can override the HandleSubtractkey method of RadMaskedNumericInput.
public
class
NumericInputMinusClearsSelection : RadMaskedNumericInput
{
protected
override
bool
HandleSubstractKey()
{
// Show Negative symnbol when all is selected.
if
(!
string
.IsNullOrEmpty(
this
.Text) &&
this
.Text.Length ==
this
.SelectionLength)
{
if
(
this
.ClearCommand !=
null
)
{
this
.ClearCommand.Execute(
null
);
}
this
.ToggleNegativeSignKey();
return
true
;
}
return
base
.HandleSubstractKey();
}
}
We have SDK example in our GitHub repository showing the mentioned above approach. Give this project a try and let us know if it works for you.
Regards,
Dinko
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.