HorizontalAlignment of CheckBox Column

4 posts, 0 answers
  1. Henrique Duarte
    Henrique Duarte avatar
    106 posts
    Member since:
    Oct 2003

    Posted 28 Jul 2009 Link to this post

    Hello,

    How can I set the HorizontalAlignment property to "Center" of a CheckBox Column (GridViewDataColumn = boolean)?

    Regards,

    Henrique
  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 29 Jul 2009 Link to this post

    Hi Henrique Duarte,

    You can achieve the desired result by using the following XAML code:

    <Grid> 
        <Grid.Resources> 
            <Style x:Key="HorizontalCell" TargetType="telerik:GridViewCell">  
                <Setter Property="HorizontalContentAlignment" Value="Center"/>  
            </Style> 
            <Style x:Key="checkEditStyle" TargetType="CheckBox">  
                <Setter Property="HorizontalAlignment" Value="Center"/>  
            </Style> 
        </Grid.Resources> 
        <telerik:RadGridView Name="RadGridView1">  
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn   
                    DataMemberPath="MyBoolColumn"   
                    CellStyle="{StaticResource HorizontalCell}">  
                    <telerik:GridViewDataColumn.EditorSettings> 
                        <telerik:CheckBoxEditorSettings   
                            CellEditStyle="{StaticResource checkEditStyle}" /> 
                    </telerik:GridViewDataColumn.EditorSettings> 
                </telerik:GridViewDataColumn> 
            </telerik:RadGridView.Columns> 
        </telerik:RadGridView> 
    </Grid> 

    Hope this helps. 

    Sincerely yours,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Mark
    Mark avatar
    8 posts
    Member since:
    Feb 2014

    Posted 09 Jun 2014 Link to this post

    Sorry, but this really needs asking:  Why isn't there a HorizontalAlignment and/or HorizontalContentAlignment property on the GridViewDataColumn?
  4. Yoan
    Admin
    Yoan avatar
    1214 posts

    Posted 09 Jun 2014 Link to this post

    Hi Mark,

    Actually, RadGridView's columns are not visual elements. This is why, you can't set those properties. As you already know you can use style targeting GridViewCell:
    <Style x:Key="HorizontalCell" TargetType="telerik:GridViewCell"
             <Setter Property="HorizontalContentAlignment" Value="Center"/> 
    </Style>
    <Style x:Key="checkEditStyle" TargetType="CheckBox"
             <Setter Property="HorizontalAlignment" Value="Center"/> 
    </Style>


    Regards,
    Yoan
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top