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

Checkbox Column Alignment

9 Answers 375 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chris
Top achievements
Rank 1
Chris asked on 06 Oct 2010, 08:47 PM
How do you center align checkbox columns in a RadGridView?

9 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 07 Oct 2010, 02:42 PM
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
0
Ariel
Top achievements
Rank 1
answered on 14 Oct 2010, 06:21 PM
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
0
david mcintyre
Top achievements
Rank 1
answered on 15 Oct 2010, 07:03 PM
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.
0
Vanya Pavlova
Telerik team
answered on 19 Oct 2010, 11:17 AM
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
0
Ariel
Top achievements
Rank 1
answered on 19 Oct 2010, 02:10 PM
Hi Vanya

That works perfect.

Thanks

Bhavik
0
Kjetil
Top achievements
Rank 1
answered on 17 Aug 2011, 10:15 AM
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
0
Vanya Pavlova
Telerik team
answered on 17 Aug 2011, 11:32 AM
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 >>

0
Kjetil
Top achievements
Rank 1
answered on 17 Aug 2011, 01:44 PM
Ah, my bad! HorizontalContentAlignment worked a lot better, yes. Thanks!
0
Jim
Top achievements
Rank 1
answered on 16 Feb 2012, 10:31 PM
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?
Tags
GridView
Asked by
Chris
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Ariel
Top achievements
Rank 1
david mcintyre
Top achievements
Rank 1
Kjetil
Top achievements
Rank 1
Jim
Top achievements
Rank 1
Share this question
or