Hello,
I have a request to display and accept negative numbers as numbers with parenthesis, for example, (450) represents -450
Does InputMask property support parenthesis in mask?
Please help ...
To clarify again:
Mask refers to an input mask. This only applies to the cell when it is in edit mode - that is, the cell is the ActiveCell and there's a blinking caret so the user can edit.
Format applies to the cell only when it is NOT in edit mode and just displaying normally.
You can format a cell using parens very easily. The DotNet framework has support for parens for negative values for most, if not all, numeric types. See the links I posted above to the standard and custom number formats in the DotNet framework.
If what you really want here is to mask the input then I'm not entirely sure what that would mean. You could create a mask with literal parens that always show up in the cell so that user is always entering a number between parens and therefore always entering a negative value. But if you want the parens to be optional and treated as negative only when the user enters them, the Infragistics masked editors don't support that. So if that's what you need - for the user to enter values optionally using parens, I would recommend not using a mask, but instead using a DataFilter to convert the string containing the parens into a negative value and the negative value back into a string.
If that is what you want, I could help you achieve it, but right now, I'm still very fuzzy on exactly what you want.
I'm afraid you lost me. You are correct that the column's DataType will pick up the DataType of the field in the data source. If you want to format the data in the tree, there's a Format property on the column. As I said, the tree basically just takes that format and passes it into the ToString method of the cell's value and uses that string in the display of the cell. So you can use any format that the DotNet framework supports for the DataType of your data.
Standard Numeric Format Strings
Custom Numeric Format Strings
Thank you Mike, I think the problem is with the cell being defined as a type that matches the datasource field. So, once a cell is defined as decimal, then applying parenthesis would not comply with numeric standards.
Perhaps there is something in Infragistics that I'm not aware of, to handle this kind of situation?
Hi Andrew, sorry for the confusion, yes you are correct, ITreeNodeColumn is not part of Infragistics. But we do use Infragistics.Win.UltraWinTree.UltraTree class. And I think when we execute SetDataBinding, all the cells in the tree are built with types that match the datasource field types. Once the cell types are defined, it would not allow me to put a custom mask such as parenthesis on a decimal cell type. If only there was a way to override these cell types then I may be able to override and define some cell as string and then put my custom mask on numeric types. Or,is there a better approach to applying custom mask in numeric cells?
Just to clarify a little bit.
If you are using Windows Form UltraTree, then you can format numeric values using parentheses for negative number. But this is a function of the DotNet framework and it's not really anything to do with the tree - except that the tree column exposes a format property and you can assign a format that gets passed into the ToString method of the cell's value when it's displayed.
Format only applies applies to the display of a cell when it is NOT in edit mode.
Masking only applies when the cell IS in edit mode. There's no way to specify a mask that takes parens for negative numbers. Bu in theory, you could use an UltraTextEditor with a DataFilter to convert "(55)" into -55 and vice versa. You would have to write the code to parse the string values and turn them into a numeric value, though.