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 ...
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.
Thanks again!
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
UltraWinGrid can display hierarchical data. But UltraSpreadsheet cannot.
So if you have the option, switching to the grid might be a good idea. But if you don't want to do that because it would be too big a change to re-write all of the application code that's currently working with the tree, I understand.
Like I said... I don't believe it's possible to mask the input of a tree cell using parens like you want. There are a number of approaches you could try, such as not using a mask, but simply letting the user type into the cell freeform and then trying to parse the parens if they are there and convert them. But there is no mask functionality to allow for optional parens.
But again... masking is for typing into a cell. If all you are concerned about here is copying and pasting, then you don't need to worry about the mask. You will have to get the data from the clipboard and parse it in code, anyway. So a mask is irrelevant.
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?
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?