8 Answers, 1 is accepted
Thank you for the referred article.
In order to achieve a similar result with the UI for WPF RadGridView you can benefit from the GridViewMaskedInputColumn. Can you please check it out? Its usage is also demonstrated in the Column Types WPF Demo so you may find it useful.
I hope this helps, Jan. Let me know in case I can be of further assistance.
Since the GridViewMaskedInputColumn uses a RadMaskedNumericInput as its editor for a Numeric MaskType, you can use the following Style to achieve your goal.
Can you please give the approach a try?
Note, that in case you need to apply the Style to a given column only, you can set an x:Key to the Style and apply it through the EditorStyle property of the column.
I hope this helps.
Thanks for the response.
The HorizontalContentAlignment works but the Placeholder just replaces the underscore with spaces. Please see attached image.
We've also tried setting AutoFillNumberGroupSeparators to false to hide the commas but we still have spaces on the left of the value.
Below is a sample of our code.
To avoid showing the placeholders you can just set the Mask property of the control to an empty string. However, this way you will loose the value restriction, like the required number of digits after and before the decimal point. If you want to have some kind of dynamic format where you want to restrict the value, but don't want the placeholders, you can try the approach shown in the DynamicFormatString SDK example. Note that, if this works for you, you will need to use a bit different approach to use the input control. Basically, you will need to use a GridViewDataBoundColumn with custom CellTemplate and CellEditTemplate that contain the custom RadMaskedNumericInput control. Or you can create a custom gridview column and override the methods responsible for creating the editor element.
If you decide to use this approach and have trouble adopting the custom control within the gridview, please don't hesitate to let me know.
Alternatively, you can use the RadNumericUpDown control with its up/down buttons hidden. I've attached a small example showing this approach. Can you please give it a try and let me know how it goes?
Hello Martin, thank you for the suggestions. Is there a way to do this on a single line? similar to how we can set Mask="#19.4" or creating an attached property (see https://www.telerik.com/forums/best-way-to-set-maxlength-on-gridviewdatacolumn#OpuGlbdurkKX2uxPqIZMhg)?
I am not sure which one you are referring to. Can you tell me which approach you want to apply using a single line of code?