This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi there, We are using numericTextBox, everything is looking good, except DecimalPlace property. If we did not set the DecimalPlace, then it will use "2" as default. eventhough we ser EnforceDecimalPlace to False. In my mind if we set the property to False, it will keep the value as much as to 2 decimal point, but if we input 3 as the value, it should display as 3 not 3.00. And if we input value 3.567, it should keep 3.57... Thanks Gordon |
|
|
Hello Gordon The EnforceDecimalPlaces is a user interaction option, not a logical option. When true, the user can not input more than the specified number of decimal places. But when false, the user can input as many decimal places as they like. You are correct to set this to false, but there are some more options I describe below that will get the effect you want. Another property I recommend you set is the FocusChangedBehavior property which you can set to Round. This means when the editor loses focus, it will round the value to the specified number of decimal places, and when it gets focus, it displays the full value with the exact number of decimal places that it has. So if the number has no decimal places, it will not show any decimal places when it gets focus. Last of all, I am assuming you are referring to a NumericTextBox you are using as an editor within the DataGrid. If this is the case, I need to point out that when the cell loses focus, the NumericTextBox is removed and a simple display element is used. This is simply a TextBlock with no formatting, so it displays the number in the default WPF way. In your scenario, you may want to provide a custom display template to change the way the number is displayed in display-mode. To do this, you can set the DisplayTemplate of the appropriate DataGridColumn to be a DataTemplate containing a TextBlock. The Text property should be binding directly to the property providing the numeric value, and you can set the StringFormat of the binding to be "0.##" which will give the effect you want. (display the value as much as to 2 decimal places). Here is an example template:
Let me know if you have any questions about this. Jason Fauchelle |
|
|
thanks Jason |
|