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 ...
My team and I have done an initial review of this issue, and I am a little unsure of what exactly you are looking to achieve. I have looked through our Windows Forms APIs and have not found any trace of an ITreeNodeColumn, and so I am not entirely sure what exactly that is. From your description, though, it sounds like you are looking to apply a Mask where if the value is within parenthesis, the editor that you are applying it to will evaluate it as a negative value?
If this is the case, this is not supported out of the box. There is no Mask that I know of that will allow you to have an input in parenthesis and evaluate that as a negative number.
I did notice that the UltraTextEditor is tagged in this forum thread. If you are using an UltraTextEditor, I don’t believe you will be able to apply a Mask anyway, as this editor cannot be masked. Assuming you are using this editor type, my best recommendation in this case would be to handle the ValueChanged event and parse the Value of the UltraTextEditor. If it is contained in parenthesis, set the Value of the editor to be the negative value of what is within those parenthesis.
Please let me know if you have any other questions or concerns on this matter.
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?
Hi Mike, I actually need to do both, format the cell, and mask the input to accept parenthesis because they want to be able to paste the amounts from Excel, and see the negative values as numbers in parenthesis. Yes I agree, changing overriding the cell types doesn't make sense. I'm just not clear how and where I can convert that string to decimal. Thank you Mike.
Okay. It's definitely possible to format the values using parens. But as I said, I'm not sure if masking is possible.
Also... the tree doesn't natively support copy and paste, so you would have to implement that yourself. In which case, there's really no reason I can see why the mask would matter. If you are copying data from Excel, then you could handle simply extracting the value from the clipboard and setting the value of the cell. You don't need to deal with masking. Masking is for USER input - like when a user it typing into a cell. It shouldn't affect pasting. Unless maybe the user is pasting a string into a single cell. And even then, you could handle getting the data from the clipboard and converting it if you need to.
It might be easier for you to use an UltraGrid instead of UltraTree. The grid has built-in copy and paste functionality and can accept copying data from Excel.
In fact, an even better choice might be to just use the UltraSpreadsheet, which is essentially exactly like Excel.
Is there some reason you are using an tree here to show spreadsheet data?
I agree, doing copy and paste onto a Tree is really not my thing. The reason I have to work with this UltraTree is because the software has been written, and it is handling a Cost Worksheet that involves drill-down of accounts and subaccounts. And not only that, the previous team of developers developed a wrapper class around Infragistics UltraTree that even added complexity with its extra properties, methods, and what nots. The top layer of the Tree node is created by instantiating this wrapper class. Maybe this was done to facilitate the copy and paste.
I think the UltraGrid and UltraSpreadhseet may not have drilldown functionality, is that a correct statement?
Sadly, many people still work with Excel, custom software at the same time. They would copy and paste from one to the other, and having two monitors is a real treat for them to keep this bad habit alive.
Well if you have any sample code to mask user input with parenthesis on a single cell, at least maybe I can see how that is done, if that can be done?
Now that I feel like I have a pretty good idea of what you want, I went ahead and created a sample project to test some of it out. And even without a mask, everything seems to work for me.
If you run my sample, you can see I have an UltraTree with some data. In both the parent and child nodes, I have a column called "decimal 1" which displays a decimal value and I am applying a Format to the column (in the UltraTree1_ColumnSetGenerated event) that makes it display negative values in parens. So far, so good.
There's no way to select a range of cells in the tree, so presumably your users are copying a single value from an Excel sheet into a single cell in the tree. So I have an UltraSpreadsheet on there and you can select a cell in the spreadsheet that contains a negative value and copy it (Ctrl+C), then click on a cell in the tree in the decimal 1 column to enter edit mode. Select all of the text in the cell and press Ctrl+V. Now... at this point, the cell with display the value with a negative sign instead of parens. I don't think that's a big problem, and Excel behaves the same say. If you click into an cell in the spreadsheet and press F2 to enter edit mode, it also shows with a negative sign instead of the parens. The parens are only for display, not for editing. And when you leave the tree cell, it once again shows the negative value with parens.
So... the only potential problem I can see here is that the cell shows the negative sign when in edit mode. But there's really nothing you can do about that and it's standard behavior even in Excel. WindowsFormsApplication8.zip
Oh thank you so much Mike, we did not expect you went thru the trouble creating the sample application. But me and our team appreciate your help very much. I will give it a try and get back with you to share our experience.