HorizontalAlignment of CheckBox Column

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

    Posted 28 Jul 2009 Link to this post


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


  2. Milan
    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:

            <Style x:Key="HorizontalCell" TargetType="telerik:GridViewCell">  
                <Setter Property="HorizontalContentAlignment" Value="Center"/>  
            <Style x:Key="checkEditStyle" TargetType="CheckBox">  
                <Setter Property="HorizontalAlignment" Value="Center"/>  
        <telerik:RadGridView Name="RadGridView1">  
                    CellStyle="{StaticResource HorizontalCell}">  
                            CellEditStyle="{StaticResource checkEditStyle}" /> 

    Hope this helps. 

    Sincerely yours,
    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
    Yoan avatar
    1215 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 x:Key="checkEditStyle" TargetType="CheckBox"
             <Setter Property="HorizontalAlignment" Value="Center"/> 

    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