I'm trying to format a column in my UltraWinGrid and seem to be stuck. The data that is bound is a string that contains only numbers (i.e. 262546500 or 1004344131). I would like this to be formatted with a dash before the last two numbers (i.e. 2625465-00 or 10043441-31). Is there a way i can do this, no amount of mask formatting seems to product the effect i'm looking for
Note that my data can be either be 9 or 10 characters long but there should always be a dash displayed before the last two characters. I do not want the underlying data changed, only the way it's displayed.
I have experimented using a variety of MaskInput values (even though i'm not inputting anything, only displaying) but the fact that there are either 9 or 10 characters seems to be causing a problem. What works for a length of 9 fails for 10, and so on. It seems as if the mask works from left to right but i'm not sure if that is the problem.
But if you want to save the data without the dash, it might be easier just to use a DataFilter. There's a decent kb article on DataFilters at http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=4877 and another one on bools which is useful.
The Format property of the grid works by calling the ToString method of the cell's Value and passing in the format. The string data type in DotNet does not support any formats, so Format will never have any effect on a string column. So you will either need to change the column to a numeric type or you can use a DataFilter, as BarraCoder suggested.