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

GridViewCheckBoxColumn cannot center

2 Answers 386 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dario Concilio
Top achievements
Rank 2
Dario Concilio asked on 14 Dec 2016, 11:41 AM

Hi to all,

I can't canter Header and cell of GridViewCheckBoxColumn...

Is it normal for specific reason?

<telerik:RadTabItem Header="Dettaglio Campi">
    <telerik:RadGridView ItemsSource="{Binding DettaglioCampiEnteCertificante}" Style="{StaticResource DettaglioCampiStyle}">
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding CampoId}" Header="ID" IsReadOnly="True"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding CampoCertificatoReference.Nome}" Header="Nome" IsReadOnly="True"/>
            <telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding Obbligatorio}" Header="Obbligatorio" TextAlignment="Center" HeaderTextAlignment="Center"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Ordinamento}" Header="Ordinamento" TextAlignment="Center" HeaderTextAlignment="Center"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding SchedeCertificatoMaterialeReference.Count}" Header="Riferimenti" TextAlignment="Right" HeaderTextAlignment="Right"/>
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>
</telerik:RadTabItem>

2 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 15 Dec 2016, 11:52 AM
Hello Dario,

The TextAlignment property of RadGridView's columns only applies to its TextBlock elements. If you need to center the GridViewCheckBox element, you could define the following style, targeting the GridViewCell element and set it as the column's CellStyle.

<Style x:Key="GridViewCellStyle" TargetType="telerik:GridViewCell" BasedOn="{StaticResource GridViewCellStyle}">
    <Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>

Regarding the HeaderTextAlignment property, if you resize the column you will notice that it is indeed applied. The reason this is not obvious in the image you provided is that space has been allocated for the filtering icon and sort indicator inside of the GridViewHeaderCell element's default control template. You can edit this template in order to achieve the desired look.

I hope you find this information helpful. Please let me know if I can further assist you in any way.

Regards,
Dilyan Traykov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Dario Concilio
Top achievements
Rank 2
answered on 15 Dec 2016, 12:45 PM
Perfect, thank you Dilyan.
Tags
GridView
Asked by
Dario Concilio
Top achievements
Rank 2
Answers by
Dilyan Traykov
Telerik team
Dario Concilio
Top achievements
Rank 2
Share this question
or