Mask = c
MaskType = Numeric
1. Negative values are not handled nicely.
The only way to stop a currency field being negative is to press the - sign.
You should be able to a. Most importantly select the - sign and press delete or backspace
b. Select all the text including the - sign and type over it (currently the new value is still negative)
c. press the + sign should make it positive
2. Is there a way to stop the user being able to enter negative values as we don't want them most time, and all i can think to do is try to stop the - keypress before it is filtered to the control.
3. Another important issue is typing over existing values
if you have a value of $800.12 entered and you select just the 8 and change it to another number lets say 7 the result is $7.12, it took out the 0's following the 8.
This is potentially hazardous, a user could easily rush through and not notice the 0's have been removed and then someone could be out quite a bit of money.
7 Answers, 1 is accepted
4. if you copy a currencey from say notepad with a value like 80.00, then select all the text in the radMaskedEditbox
and press CTRL+V (paste) the result in the Masked edit box is as follows $080.00.00 note the two decimal points, this can not be achived by simple typing a second decimal so the paste should not allow it.
5. The MaxLength does not function.
I have opened the control editor for the RadMaskedEditBox and under the RadMaskedEditBoxItem treenode there is a property for MaxLength, setting this has no effect what so ever.
We use the RadMaskedEditBox to enter cost fields which are saved to the database so it would be nice to limit these to only values that the SQL server money field will accept, Max length would do the trick quite nicely.
I know we could add a validation routine to our form to check this and report to the user about invalid values, but even better is them not being able to add them in the first place, and this would save us a lot of repeat code adding validation.
Is there another way to set the max length or limit the values able to be entered.
There are quite a few questions here so I may need to answer them over a few replies.
Please see the code below. It is just a RadMaskedEditBox on a form.
This should address a couple of your issues:
1: Does not allow minus values
2: Corrects the copy and paste problem
I will try and get back to you with a workaround to your other issues.
hope that helps
I tried the internal TextBoxItem for MaxLength as well, but this didn't function as I expected, so the following code has been revised to include a max length functionality.
I hope this all helps. Please mark as answer anything you found useful and if you need more information, just let me know.
Ok, let's take them one by one,
First, for the Num + sign to make the value positive and for the Num - to make the value negative you can use the following:
For the copy paste you can use Richards suggestion, it should do what you need.
Hope this helps, if you have any other questions or comments, please let me know,
Telerik WinForms MVP
these workarounds did fix my problems, I am adding them all to a class that inherits from the radMaskeditBox and making a new currencey text box to use within our program.
The only real issue we have left was the point 3. from my first post in this thread.
Following your samples I have also coded a fix to allow deleting the minus sign from the start to make a positive number
You just add this code to a class inheriting the RadMaskEditBox
Private Const WM_KEYDOWN As Long = &H100
Protected Overrides Function ProcessKeyPreview(ByRef m As System.Windows.Forms.Message) As Boolean
' If allowing neagative values this is a fix to allow deleting the minus sign
If m.Msg = WM_KEYDOWN Then
If m.WParam = Keys.Back Or m.WParam = Keys.Delete Then
If Me.Value < 0 Then
If Me.SelectedText = "-" Then
Me.Value *= -1
Glad that this is all sorted for you and we were able to help.