I have an application that uses the UltraMaskedEdit control for integers and decimals. When a user types in "000", "0", or ""; the value of the control is zero, however the text of the control remains as the user typed.
I am using input masks "nnnn" and "nnn,nnn.nn". I would like, on field leave, for these to be displayed as "0" and "0.00" respectively if the user typed in something that equates to zero. If the user types in "004", I would like it to display "4" and "4.00" respectively.
My current working solution is to set the value of the control to the text of the control on leave, however I would greatly prefer to use integrated functionality instead. Attached is a VS2010 project that can be used to duplicate this behavior.
The code in the field leave event that is my current solution:
If IsDBNull(Me.Value) Then Me.Text = 0 Else Me.Text = Me.Value End If
Hello,
Please try the following, without setting InputMask:
newControl2.FormatString = "####"
Please do not hesitate to contact me if you need any additional assistance.
Doing that causes the field to display nothing when the value is 0, I would like it to always display 0 if the value is zero. However, that does remove the leading zeroes on field leave which is good.
However, I do not believe this solution will work as the Input Mask is used to format the numbers while the user is typing them. The number format changing when a user clicks on a field (removing commas and changing decimal point display location) is not desirable.
We currently use v8.3 in our application, however we are also considering moving to v11.2.
Your requirements seem to be uncommon and I believe that this should be achieved on leaving the field. So your first approach is good enough for this situation.