<telerik:GridViewMaskedTextBoxColumn DataMemberBinding="{Binding PriceChangePercent}" Header="Price Change Percent" MaskType="Numeric" Mask="p"/>
<telerik:GridViewMaskedTextBoxColumn DataMemberBinding="{Binding MarketValue}" Header="Market Value" MaskType="Numeric" Mask="c"/>While viewing the cell the mask does not show, when editing the cell you see the mask, but the percent mask moves the numbers around. How can I get the mask to show in the view state, and show the values correctly?
Attached images of the columns above.
These cells should always be read only. I changed them to be editable to help debug this issue.
Thanks
7 Answers, 1 is accepted
In the case of GridViewMaskedTextBoxColumn the editing element is RadMaskedTextBox. Consequently, the properties set are reflected on editing the value. What you may do is do use the DataFormatString property of the column. Furthermore, if you want more of the digits after the decimal point to be displayed, you need to define the Mask more precisely. For example:
<telerik:GridViewMaskedTextBoxColumn DataMemberBinding="{Binding StadiumCapacity}"
Mask="p4" MaskType="Numeric" DataFormatString="{}{0:P4}"/>Maya
the Telerik team
I used your code:
<telerik:GridViewMaskedTextBoxColumn DataMemberBinding="{Binding PriceChangePercent}"Header="Price Change Percent" Mask="P4" MaskType="Numeric" DataFormatString="{}{0:P4}" />If I set mask why does it not set both viewing and editing? I can see the extra functionality of being able to set viewing and editing separate(for what use I have no idea), but if a user wants this then let them set both. I would think 99% of the time the user will want the edit/view masks to be the same, so why does it not set both masks to be the same, and the user has the ability to overwrite the second mask if they so choose.
Since this grid is read only I see no benefit in using the GridViewMaskedTextColumn over the GridViewDataColumn since I still have to set the DataFormatString.
As mentioned previously the RadMaskedTextBox is the editing element in the corresponding column. It is the same case with the GridViewComboBoxColumn where the RadComboBox shows up only in edit mode. Furthermore, the fact that the numbers are rounded is due to setting the Mask and MaskType properties. However, if you try to play along with the definition of the Mask - P8 for example, more digits will be displayed.
Thus you may arrange the settings so that they meet your requirements.
Maya
the Telerik team
Controls for Silverlight
When I set a mask why does the mask not get set for the editing and viewing controls? Why must I set the mask twice? I understand that the editing and viewing state are different controls, but the mask on both controls should be set at the same time.
I know that if my number is 1.2345678 and I set a mask of 0.000 that you will see 1.234. Attached is a screen shot(telerik.png). The columns are the same in code. The value is -4.1694242223692900, but when the cell goes to editing it becomes -416.94 %. This is unacceptable. The control is changing the value. With a % mask it should be -4.16 %. Controls should never change values in the cell. I don't see a setting that stops this from happening. I don't want to show more digits, I want the control to stop moving my decimal point.
The control in view mode is plain TextBlock which does not have anything closer to masking. Why you need GridViewMaskedTextBoxColumn at all if these cells should always be read only? The main purpose of this column is to edit your data with RadMaskedTextBox - if your scenario is different you should use plain GridViewDataColumn with desired format for the binding or DataFormatString.
Greetings,Vlad
the Telerik team
I will still need to set the Mask, MaskType, and DataFormatString. I don't understand why when I set the Mask and MaskType, it can not set the DataFormatString at the same time. Given the percent example if I set Mask="P4" that should be the same as setting DataFormatString="{}{0.0000}%".
Also what happens when then Mask property on masked editor is set to P? Why does the number change? Is the control doing a *100 to the value?
DataFormatString is exactly the same as string.Format() while Mask and MaskType are a bit more complicated.
The Numeric RadMaskedTextBox with mask "P" uses by default the method ToString() of the type of the value. This formatting basically multiplies the value with 100. You can test it like so;
double value = 68d; MessageBox.Show(value.ToString("p"));Feel free to ask if you need further assistance. We would be glad to help you.
Kind regards,
Petar Mladenov
the Telerik team

