This is a migrated thread and some comments may be shown as answers.

How to format Phone Numbers with GridViewMaskedTextColumn

2 Answers 220 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Louis
Top achievements
Rank 1
Louis asked on 01 Mar 2011, 12:31 AM
I'm trying to set a mask for phone numbers in a grid using the GridViewMaskedTextBoxColumn, but it doesn't seem to be working.  The XAML I'm using is as follows:

<telerik:GridViewMaskedTextBoxColumn x:Name="colCellPhone" Header="Cell Phone" DataMemberBinding="{Binding MobilePhone}" MaskType="Standard" Mask="###-###-####"  IsReadOnly="True" IsGroupable="False" IsFilterable="False" Width="*" />

However, when running the application the phone number displays without the mask.  What does it take to get the masking to work?

Thanks

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 01 Mar 2011, 08:26 AM
Hello Louis,

You may define the DataFormatString property of the GridViewDataColumn:

<telerik:GridViewDataColumnDataMemberBinding="{Binding MyProperty}"DataFormatString="{}{0:(###) ### - ####}"/>

However, this format will not be used when the cell is in edit mode. A possible approach to keep the format both in view and edit mode is to use the GridViewMaskedTextBoxColumn as follows:

<telerik:GridViewMaskedTextBoxColumnMask="(###) ### - ####"MaskType="Standard"
    DataMemberBinding="{Binding MyProperty}"DataFormatString="{}{0:(###) ### - ####}"/>
I am sending you a sample project illustrating both approaches.

 

Regards,
Maya
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Louis
Top achievements
Rank 1
answered on 02 Mar 2011, 12:54 AM
Thanks Maya,

     This syntax is a bit different than the example given in the documentation, but as long as it works.
Tags
GridView
Asked by
Louis
Top achievements
Rank 1
Answers by
Maya
Telerik team
Louis
Top achievements
Rank 1
Share this question
or