Despite reading all I can find on using a TcxMaskEdit I cannot work out what mask I need. Can you help?
I want the user to be able to enter any positive number (not negative, not zero). Examples: the mask needs to allow the following:
0.00001
1E-5
1e-5
1000000
1E6
1e6
145
1.45e2
Any valid entries will be stored in a numeric database field so entries like "1E6" should be returned from the MaskEdit as 1000000.
Is this possible?
(Yes, I know I am not on the latest version of your components.)
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hello Steven.
Thank you for your message.
I think that you should use the following mask:
[+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?
It allows you to enter any positive number using decimal numbers or scientific notations.
However, this mask allows entering a zero value. To prevent this you can use the editor's Properties.OnValidate method as follows:
procedure OnValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); begin if DisplayValue = 0 then DisplayValue := 1; end;
Attached is an example that shows how to perform this task.
Does this solution meet your requirements?
P.S. Please review the following web-page that contains a lot of regular expressions that can be used in our cxMaskEdit:
http://www.regexlib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3
Best regards,
Ingvar.
Yes, that works very nicely. Thank you.