How to modified text 's color of header

4 posts, 0 answers
  1. Totti
    Totti avatar
    10 posts
    Member since:
    Sep 2010

    Posted 27 Sep 2010 Link to this post

    I have telerik:RadGridView  control, I want to set text 's color of header for Grid, I tried some ways as implement behind code, set property in XAML file, but I can't set color for text of Grid's header. (I'm using the latest ver of SilverLight 4.0 )
    - case of XAML file:

     <Grid Grid.Row="3" Grid.Column="1" Margin="15,15,15,12" Grid.RowSpan="2">
                                    <Style x:Key="GridViewHeaderRowStyle" TargetType="telerik:GridViewHeaderRow">
                                        <Setter Property="Template" Value="{StaticResource GridViewHeaderRowTemplate}"/>
                                        <Setter Property="Background" Value="#CC0010"/>
                                        <Setter Property="Foreground" Value="White"/>
                                    <ColumnDefinition Width="0.041*"/>
                                    <ColumnDefinition Width="0.145*"/>
                                    <ColumnDefinition Width="0.814*"/>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="auto"/>
                                    <RowDefinition Height="30"/>
                                <telerik:RadGridView Grid.Row="0" AutoGenerateColumns="False" Name="grdRDFMatrix"
                                    ColumnWidth="*" GridLinesVisibility="Horizontal"
                                    IsReadOnly="True" ItemsSource="{Binding DataList, Mode=TwoWay}"                                      
                                    ShowGroupPanel="False"  Grid.ColumnSpan="3"   telerikGridViewFilter:CustomFilterRow.IsEnabled="True"
                                        <telerik:GridViewDataColumn Header="Rate" UniqueName="Rate" Width="*"  HeaderCellStyle="{StaticResource GridViewHeaderRowStyle}" />
                                        <telerik:GridViewDataColumn Header="Destination" UniqueName="Destination" Width="*" HeaderCellStyle="{StaticResource GridViewHeaderRowStyle}"/>
                                        <telerik:GridViewDataColumn Header="Format" UniqueName="Format" Width="*" HeaderCellStyle="{StaticResource GridViewHeaderRowStyle}" />
                                        <telerik:GridViewDataColumn Header="Fee Table" UniqueName="FeeTable" Width="*" HeaderCellStyle="{StaticResource GridViewHeaderRowStyle}"/>
                                <telerik:RadDataPager Grid.Row="1" Template="{StaticResource RadDataPagerTemplate}"
                                       PageSize="{Binding Value, ElementName=Pagesize,Mode=TwoWay}"
                                       Source="{Binding Items, ElementName=grdRDFMatrix}"
                                       IsTotalItemCountFixed="True"  Grid.ColumnSpan="3" />
                                <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2" Width="200">
                                    <TextBlock Text="Page Size" VerticalAlignment="Center" />
                                    <telerik:RadMaskedTextBox MaskType="Numeric" Mask="d3" Name="Pagesize" Height="23" Width="40" Margin="7,0,0,0" Value="10" TextAlignment="Center"/>
                                <Grid Grid.Row="2" Grid.ColumnSpan="3" >
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="*"/>
                                    <Button Grid.Column="0" Content="Save" Width="66" Height="25" VerticalAlignment="Center" Command="{Binding SaveRDFCommand}" CommandParameter="InsertRDFMatrix" HorizontalAlignment="Left"/>
                                    <Button Content="Associate" Height="25" Grid.Column="1" HorizontalAlignment="Center" Width="83" VerticalAlignment="Center" Click="btnAssociate_Click"/>
                                    <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,5,0">
                                        <HyperlinkButton Content="Import" Grid.Column="1" FontSize="12"  Name="lnkImport" VerticalAlignment="Center" Grid.Row="2" />
                                        <TextBlock Grid.Column="1"  Text="/" VerticalAlignment="Center" FontSize="12" Margin="5,0,5,0"/>
                                        <HyperlinkButton Content="Export" Grid.Column="1"  Name="lnkExport" FontSize="12" VerticalAlignment="Center"/>

                        <Button Click="btnNextFT_Click" x:Name="BtBottomRight" Content="" Grid.Column="1" Grid.Row="4" HorizontalAlignment="Right" VerticalAlignment="Center"  Style="{StaticResource ArrowButton}"  Width="28" Grid.ColumnSpan="2" Margin="0,130,97,80">
                                <CompositeTransform Rotation="90"></CompositeTransform>
    - Case of code hehind:

     this.grdRDFMatrix.DataLoaded += new System.EventHandler<System.EventArgs>(grdRDFMatrix_DataLoaded);
     private void grdRDFMatrix_DataLoaded(object sender, System.EventArgs e)
                foreach (var col in this.grdRDFMatrix.Columns)
                    col.HeaderCellStyle = (Style) this.Resources["GridViewHeaderRowStyle"];


    More: I changed successfully with background property but impossible with Foreground.
    It's better, if you have simple example about change text 's color of header Grid using Foreground property.
  2. Maya
    Maya avatar
    4062 posts

    Posted 27 Sep 2010 Link to this post

    Hello Totti,

    You can try to set a style targeting the GridViewHeaderCell:

    <Style TargetType="telerik:GridViewHeaderCell">
        <Setter Property="Foreground" Value="HotPink"/>
        <Setter Property="Background" Value="Azure" />         

    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. Claudio
    Claudio avatar
    4 posts
    Member since:
    May 2012

    Posted 11 Aug 2013 Link to this post

    Is there a way to control a grid header foreground and background individually? Meaning not change all the column headers to the same color or same text? i'm using GridViewTextBoxColumn in WinForms version 2012.2.912.40
  4. Maya
    Maya avatar
    4062 posts

    Posted 12 Aug 2013 Link to this post

    Hi Claudio,

    Will it be possible to post your question on the related WinForms telerik forum ?
    Thank you in advance.  

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top