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

GridViewMaskedTextBoxColumn's Mask as a Style Property

1 Answer 59 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hyddude
Top achievements
Rank 1
Hyddude asked on 09 Mar 2012, 11:58 PM
Hi,

I am working on an audit application where I use lot of GridViews. There are columns such as SSN, Date, accountnumbers ..etc which I use in a lot of grids. Every column is initially in readonly mode has edittrigger set to F2.  For SSN I am using GridViewMaskedTextBoxColumn and defined it as below

<telerikGrid:GridViewMaskedTextBoxColumn DataMemberBinding="{Binding SSN, Mode=TwoWay,
Converter={StaticResource ssnConverter}}" Header="SSN" EditTriggers="F2" Mask="###-##-####"
 MaskType="Standard" />              

When I write a Style as below :

<Style x:Key="SSN_GridViewColumn" TargetType="{x:Type telerik:GridViewMaskedTextBoxColumn}">
            <Setter Property="Mask" Value="###-##-####"/>
            <Setter Property="Header" Value="SSN"/>
            <Setter Property="MaskType" Value="Standard"/>
            <Setter Property="EditTriggers" Value="F2"/>
 </Style>

and try to apply them to all the SSN columns in my grids, I get runtime errors regarding the Properties "Mask" and "MaskType" properties in the Style. They only work when I add them explicitly in the Column defiition rather than in the style. Is this an Issue with MaskedTextBoxColum

Is there any other alternative to this?

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 12 Mar 2012, 08:09 AM
Hello,

 You cannot use styles for columns. It will be better to create custom column inherited from GridViewMaskedTextBoxColumn and set desired settings in CreateCellElement for the masked textbox

Kind regards,
Vlad
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
GridView
Asked by
Hyddude
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or