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

GridViewDataColumn - how to limit the number of characters when editing

7 Answers 565 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 17 Dec 2010, 04:38 PM
How do you limit the number of characters that can be entered.


 

 

<telerikPresentation:GridViewDataColumn x:Name="units" DataMemberBinding="{Binding bale_cnt, Mode=TwoWay}" Header="Units" Width="95" TextAlignment="Right" />

 

 

7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 20 Dec 2010, 08:46 AM
Hi,

 You can define CellEditTemplate with desired controls/customizations. 

Greetings,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Jon
Top achievements
Rank 1
answered on 20 Dec 2010, 01:50 PM
Where can I find an example of the celledittemplate that limits the number of characters that can be entered?
thx
0
Vlad
Telerik team
answered on 20 Dec 2010, 02:13 PM
Hello,

 We don't have such example. The idea is to use TextBox in this template where you can set desired value for MaxLength property.

Regards,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Jon
Top achievements
Rank 1
answered on 20 Dec 2010, 02:19 PM
Ok.. thanks.
0
Tore
Top achievements
Rank 1
answered on 22 Mar 2011, 07:23 PM
Example follows 

..

  <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Hemit.OpPlan.Client.Module;component/Common/Resources/OpPlanStyles.xaml" />                          
            </ResourceDictionary.MergedDictionaries>

            <Style TargetType="{x:Type TextBox}" x:Key="PasGroupCodeStyle">
                <Setter Property="MaxLength" Value="2" />
            </Style>

        </ResourceDictionary>
    </UserControl.Resources>

    <Grid>
.... 

   <telerik:RadGridView
            Grid.Row="1"
            Style="{StaticResource EditableGridViewStyle}"
            ItemsSource="{Binding ModelCollection}"
            RowIndicatorVisibility="Collapsed"
            CanUserFreezeColumns="False"
            AutoGenerateColumns="False"
            ShowGroupPanel="False"
            SelectedItem="{Binding SelectedModel, Mode=TwoWay}">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="Kode" DataMemberBinding="{Binding Code}" Width="300" EditorStyle="{StaticResource PasGroupCodeStyle}" />
                <telerik:GridViewDataColumn Header="Beskrivelse" DataMemberBinding="{Binding Text}" Width="300" />
                <telerik:GridViewDataColumn Header="Er aktiv" DataMemberBinding="{Binding IsInUse}" Width="80" />
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>


..

-=The Norse Viking=- 
0
Tore
Top achievements
Rank 1
answered on 22 Mar 2011, 07:25 PM
Key points : EditorStyle + Style with targettype textbox and MaxLength set to 2
0
Anne
Top achievements
Rank 1
answered on 01 Jul 2015, 06:33 PM
Awesome!! Very helpful!
Tags
GridView
Asked by
Jon
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Jon
Top achievements
Rank 1
Tore
Top achievements
Rank 1
Anne
Top achievements
Rank 1
Share this question
or