StrataFrame Forum

Masks on a numeric field

http://forum.strataframe.net/Topic16648.aspx

By Ger Cannoll - 5/28/2008

How do I mask a numeric field.

e.g. if 1234.9900 and I want to display/ enter as 1234.99, even better if it was a negative no. if it can be displayed in red . In vfp there's a Mask proerty but I cant see similar property in .net or startaframe classes. Same one apply to Bank Sort Code (e.g. 123456 to be displayed as 12-34-56

By Trent L. Taylor - 5/28/2008

You will want to use the MaskedTextBox or a NumericUpDown control to enter numeric data and supply a mask.  You can technically also use the BindingFormat of a standard textbox, but in this case I would recommend using the MaskedTextBox instead.
By Paul Chase - 5/28/2008

Gerard,

There is masked textbox control where you can set an input mask.

By Ger Cannoll - 5/28/2008

Hi. I tried Mask on MaskedTextBox with a mask of 00,000.00 and tried 999,999.99 but say 3.17 was displayed as 317,000.0    what am I doing wrong ?
By Paul Chase - 5/28/2008

Hi Gerard,

I don't personally use the masked textbox so couldn't help you much with how the masking work's, I use Dev Express controls which have really nice masking features built into them so I never have used the standard masked text box I just knew it was there in the toolbox. Smile

Since the masked textbox is a just a standard winforms control I'm sure there should be info available either in msdn documentation or via a google search on how to use that control.

Paul

By Edhy Rijo - 5/28/2008

Hi Gerarld,

Try setting the control's BindingFormat property = c2 in the Properties windows.