GridViewDataColumn - how to limit the number of characters when editing

8 posts, 0 answers
  1. Jon
    Jon avatar
    539 posts
    Member since:
    Apr 2004

    Posted 17 Dec 2010 Link to this post

    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" />

     

     

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 20 Dec 2010 Link to this post

    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
  3. Jon
    Jon avatar
    539 posts
    Member since:
    Apr 2004

    Posted 20 Dec 2010 Link to this post

    Where can I find an example of the celledittemplate that limits the number of characters that can be entered?
    thx
  4. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 20 Dec 2010 Link to this post

    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
  5. Jon
    Jon avatar
    539 posts
    Member since:
    Apr 2004

    Posted 20 Dec 2010 Link to this post

    Ok.. thanks.
  6. Tore
    Tore avatar
    4 posts
    Member since:
    Mar 2011

    Posted 22 Mar 2011 Link to this post

    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=- 
  7. Tore
    Tore avatar
    4 posts
    Member since:
    Mar 2011

    Posted 22 Mar 2011 Link to this post

    Key points : EditorStyle + Style with targettype textbox and MaxLength set to 2
  8. Anne
    Anne avatar
    1 posts
    Member since:
    Jul 2015

    Posted 01 Jul 2015 in reply to Tore Link to this post

    Awesome!! Very helpful!
Back to Top