According to the documentation, a mask of (999) 000-0000 would show parentheses surrounding 3 optional numerals and then 7 mandatory numerals. This doesn't work at all, it shows the first 3 numerals followed by 7 zero's. using combinations of 9's and pound signs still fills the parentheses first and leaves unused mak at the end.
I have a column that is saved as text, either 7 or 10 numerical characters. If there are 7 I want them displayed as "() 555-1212" and if there are 10 I want "(555) 555-1212".
Thanks for your help.
Bob
Hi Bob,
I'm not sure where in the help you are looking, but my guess is that the help topic in question assumes that the value of the cell is numeric, not string, since 9 and 0 are numeric mask characters.
Thanks for the reply Mike,
Yes, I was looking at the wrong help topic, but the question still stands. I ended up using an ultraMaskedEdit as an edit control, and then using a hack in my sql query to prepend four spaces in front of the phone number if it only had seven digits. This works correctly for loading, display and editing. There was still a small issue though, that the cell wouldn't display the mask until I fiddled around quite a bit. Finally I figured out that if I went into the designer.cs file and added a line: ultragridcolumn.Format = ""; it would display right when I went back to the design view of the grid. This may be an issue with vs 2008/.net 3.5 compatibility. In the end, I'm going to abandon this pursuit and create a default area code that will be prepended if the user doesn't supply one.
As a side question, is there a way to get a mask to only display literals if the optional characters are present? Such as zip codes that are #####-9999, I just want "01234" not "01234-" if the plus 4 zip is not provided. For a phone number with optional Ext I just want the root phone number in MaskDisplay if there is not extension provided. As it is now, I get "(321) 123-4567 Ext." with a mask of (###) ###-#### Ext.999 . I'd like to hide the literals "Ext." if the extension is not provided.
Thanks, Bob Graham
Thanks for your help on that second question. On the first issue, yes, I was still confused, the Format = "" thing doesn't seem to be necessary if your MaskedEdit control is set up properly. Oh, well, I learned a lot.
Maybe I'll submit a feature request to hide literals that end up hanging at one end of a string unused, though, it would have to be an optional setting as obviously it wouldn't always be the right choice.
Just so you know, the Format property of the column takes effect when the cell does not have focus, and the MaskInput is for when it does have focus.
To answer yout question, no, I don't beleive you can hide literals in a mask conditionally.