GridViewCheckBoxColumn cannot center

3 posts, 0 answers
  1. Dario Concilio
    Dario Concilio avatar
    180 posts
    Member since:
    Apr 2016

    Posted 14 Dec 2016 Link to this post

    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. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    1173 posts

    Posted 15 Dec 2016 Link to this post

    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.
  3. Dario Concilio
    Dario Concilio avatar
    180 posts
    Member since:
    Apr 2016

    Posted 15 Dec 2016 in reply to Dilyan Traykov Link to this post

    Perfect, thank you Dilyan.
Back to Top