Hi
I have an
UltraNumericEditor and I Set minimum value to 1 maximum 999
But it allows us to enter manually using key board a value like 0
which it should not allow us at all when min and max values are set
And I press tab its stuck there for ever, is there any solution to avoid entering zero when minimum value is 1
help is appreciated
thanks and regards
venugopal darur
Hi,
The cell value is not validated against the minimum until the user tries to leave the cell. It really has to be that way, because the grid can't know what the user is going to type next.
I guess in a case like this, there's no reason to allow the user to type a leading 0, but the grid doesn't have any functionality built in to stop them.
You might want to try applying a Mask to the column like "nnn". That might do what you need.
Oops. please ignore the above, for some reason, I thought this was a grid question.
What is the mask you are using? Try using "nnn" or "###' and see if that makes any difference. If not, then the only thing to do would be to try handling this yourself in KeyDown, maybe.
The mask idea did not work. Used the keyPress event. Why does the MinValue property not work? Just looking for a simple 1 through 10 numeric editor and had to add the following code:
Private Sub uneOneThruTen_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles uneOneThruTenKeyPress
Try
If (e.KeyChar = "0") Then
If (uneOneThruTen.Value <> 1 And uneOneThruTen.SelectionLength <> 0) Then
e.Handled = True
End If
Catch 'ignore errors
End Try
End Sub
The MinValue does work and it will prevent you from leaving the control if the value you entered is not within the acceptable range.
The control cannot validate the entire value of the control on every keystroke, because it doesn't know what the user may type next. "0" is a perfectly valid character because the user could enter "01", for example.
I was able to leave the control with the 0 in place. I am also able to leave the control after deleting or backspacing the value. Checking on the leave event, the actual value of the control differs then what is being displayed. I ended up adding the following:
Private Sub uneOneThruTen_Leave(sender As System.Object, e As System.EventArgs) Handles uneOneThruTen.Leave
If (Not uneOneThruTen.Editor.IsValid) Then
uneOneThruTen.Value = 1
If MinValue and MaxValue are 1 and 10 respectively, and you are still able to leave the control with a value of "0", then something is wrong. Either you are using an old version of the controls that had a bug in it, or something in your code is incorrect - like perhaps you are re-setting the MinValue to something else. Or maybe you code is handling the Validating event and letting it go through.
I tried this out in a small sample project just to make sure it's working correctly, and it works just fine for me. I attached my sample here in case you want to try it for yourself.
Hi Matt,
Try getting the latest service release:
How to get the latest service release - Infragistics Community
If that doesn't help, I think you will need to upgrade. Or just go with the workaround you have.
Must be the version issue. Created a clean project with the same results. Version of the contriols I am currently using is 10.2.20102.1004.
Thanks,
Matt