Checkbox Column Alignment

10 posts, 0 answers
  1. Chris
    Chris avatar
    1 posts
    Member since:
    Jul 2010

    Posted 06 Oct 2010 Link to this post

    How do you center align checkbox columns in a RadGridView?
  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 07 Oct 2010 Link to this post

    Hello Chris,

     
    You can center the checkboxes in GridViewCheckBoxColumn through defining a simple style, use the following markup:

    <Style TargetType="telerik:GridViewCheckBox">
       <Setter Property="HorizontalAlignment" Value="Center"/>
    </Style>

     

    All the best,
    Vanya Pavlova
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Ariel
    Ariel avatar
    9 posts
    Member since:
    Aug 2010

    Posted 14 Oct 2010 Link to this post

    Hi Vanya

    I had the same question. Your solution solved the problem partially. What about if I want the Checkbox to be centered also while editing. How can I achieve that.

    Thanks,

    Bhavik
  4. david mcintyre
    david mcintyre avatar
    31 posts
    Member since:
    Mar 2010

    Posted 15 Oct 2010 Link to this post

    i was able to center the checkbox when it's in editmode by creating a new default style w/ target type = GridViewEditorPresenter.  But could only get it to work by setting it as a nameless default style.  i can't figure out what column style property to apply it to.
  5. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 19 Oct 2010 Link to this post

    Hello Bhavik,

    In order to be able to center the GridViewCheckBox through editing you should create style that is targeted at GridViewCell and set its HorizontalContentAlignment property to Center and apply that style to the GridViewCheckBoxColumn.

    Please check the attached project that illustrates this approach. 

    Kind regards,
    Vanya Pavlova
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Ariel
    Ariel avatar
    9 posts
    Member since:
    Aug 2010

    Posted 19 Oct 2010 Link to this post

    Hi Vanya

    That works perfect.

    Thanks

    Bhavik
  7. Kjetil
    Kjetil avatar
    13 posts
    Member since:
    Oct 2010

    Posted 17 Aug 2011 Link to this post

    Hi,

    I tried to apply the same solution in a WPF gridview, but as you can see from the attached image the result wasn't all that great... The image shows two checkboxes - one with the style applied and one without. The code can bee seen above the designer.

    sincerely,

    Kjetil Klaussen
  8. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 17 Aug 2011 Link to this post

    Hello Kjetil,

     
    As suggested in my previous reply you should use HorizontalContentAlignment instead. 


    All the best,
    Vanya Pavlova
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  9. Kjetil
    Kjetil avatar
    13 posts
    Member since:
    Oct 2010

    Posted 17 Aug 2011 Link to this post

    Ah, my bad! HorizontalContentAlignment worked a lot better, yes. Thanks!
  10. Jim
    Jim avatar
    4 posts
    Member since:
    Nov 2010

    Posted 16 Feb 2012 Link to this post

    Can you tell me how this can be done programatically? I need to be able to dynamically add columns with checkboxes in the grid and need them centered. Do you have a C# example?
Back to Top