Is there a way to stop this from happening?
7 Answers, 1 is accepted
This is expected from this control. If you would like to remove this then I'd suggest setting the Max to a higher value and then validating the value as you would with a textBox.
Hope that helps but let me know if you have any further questions
Richard
It seems logical that, at a minimum, I should be able to receive an event notification from the control that IT is changing the value (and not the user changing the value). Do you know of an event that will tell me when the control decides to "validate" and change my invalid 110 to a 100?
I beleive that this is the case because whilst you are typing, the control is still editing. The max value is changing, whilst you have compared it with a textbox that validates against string length which is different.
you can subscribe to the property changed event and see the value changed
AddHandler
Me
.RadSpinEditor1.SpinElement.PropertyChanged,
AddressOf
PropertyChanged
Public
Sub
PropertyChanged(
ByVal
sender
As
Object
,
ByVal
e
As
PropertyChangedEventArgs)
If
e.PropertyName =
"Value"
Then
MessageBox.Show(
"Value Changed"
)
End
If
End
Sub
However, to get over your issue, I'd suggest something like this. You just need to add an ErrorProvider..
In form load or similar
AddHandler
Me
.RadSpinEditor1.SpinElement.TextBoxItem.Validating,
AddressOf
RadSpinEditor_TextValidating
AddHandler
Me
.RadSpinEditor1.SpinElement.TextBoxItem.Validated,
AddressOf
RadSpinEditor_TextValidated
AddHandler
Me
.RadSpinEditor1.Leave,
AddressOf
RadSpinEditor_Leave
Me
.RadSpinEditor1.Minimum = 0
Me
.RadSpinEditor1.Maximum = 999
Public
Sub
RadSpinEditor_Leave(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Me
.RadSpinEditor1.SpinElement.Validate()
End
Sub
Public
Sub
RadSpinEditor_TextValidating(
ByVal
sender
As
Object
,
ByVal
e
As
CancelEventArgs)
If
Me
.RadSpinEditor1.Value > 100
Then
Me
.ErrorProvider1.SetError(
Me
.RadSpinEditor1,
"Value cannot be over 100"
)
e.Cancel =
True
Me
.RadSpinEditor1.SpinElement.TextBoxItem.SelectionStart =
Me
.RadSpinEditor1.SpinElement.TextBoxItem.Text.Length
End
If
End
Sub
Public
Sub
RadSpinEditor_TextValidated(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Me
.ErrorProvider1.SetError(
Me
.RadSpinEditor1,
""
)
End
Sub
Hope that helps but let me know if you have further questions
Richard
Did you find this helped? If so, please remember to mark as answer,
thanks
Richard
Thank you Richard for your solution.
In order to make our RadSpinEditor more convenient for our users, we mimic the behavior of the standard Microsoft NumericUpDown control. We cannot validate the way the user types a value. For example, if one wants to enter 17,8 and starts typing 178, then presses the left arrow key and finally types ','.
You can use the solution provided by Richard.
I hope this helps.
Kind regards,
Peter
the Telerik team
Thanks guys. I ended up implementing my own control, using the RadSpinEditor as the base control. The users are much happier with it and its behavior.
One thing I'd recommend however; I wouldn't expect the caller of a control to have to use string comparisons to know what value is changed in the PropertyChanged() event. That seems really messy to me. I'd prefer that perhaps the event arguments to a PropertyChanged() event to contain maybe an Enum with the value containing what property changed.
For instance. Have the following enum..
enum PropertyTypeEnum { Value, Text, Color, Size }
and then in your PropertyChanged(object sender, PropertyChangedEventArgs e) have a property called
e.PropertyType of Type (PropertyTypeEnum) so that I could just do something like the following...
if(e.PropertyType == PropertyTypeEnum.Value)
{
.... do stuff here
}
Thank you for writing back.
I would like to inform that PropertyChanged is a method of the Microsoft INotifyPropertyChanged interface and its parameters cannot be changed. In our TPF, we are using RadPropertyChanged where we implement a comparison between types, for example:
protected
override
void
OnPropertyChanged(RadPropertyChangedEventArgs e)
{
if
(e.Property == RadElement.VisibilityProperty)
{
I hope this helps.
Kind regards,
Peter
the Telerik team