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

How do I change column headers at runtime?

5 Answers 155 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jerry Kurata
Top achievements
Rank 1
Jerry Kurata asked on 08 Jul 2010, 05:33 PM
Hi,

We have a requirement to allow users to change the column header formatting and text at runtime.  Changing the text appears easy enough, but I am not sure how to change the formatting.  Users need to be able to set the Font Family, size, bold, italics, underline and color for the Column header.  Do you have a sample showing this?

Thanks,
Jerry

5 Answers, 1 is accepted

Sort by
0
Accepted
Yavor Georgiev
Telerik team
answered on 08 Jul 2010, 05:37 PM
Hello Jerry Kurata,

 You can insert a TextBlock in the column's header and bind its various properties.

<telerik:GridViewColumn>
  <telerik:GridViewColumn.Header>
    <TextBlock Text="{Binding HeaderText}" FontFamily="{Binding HeaderFont}"/>
  </telerik:GridViewColumn.Header>
</telerik:GridViewColumn>

Kind regards,
Yavor Georgiev
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
Jerry Kurata
Top achievements
Rank 1
answered on 08 Jul 2010, 07:15 PM
Thanks.  That did the trick!
0
Jerry Kurata
Top achievements
Rank 1
answered on 13 Jul 2010, 09:05 PM
Hi,

This change created a problem with exporting the data to excel, word, etc.  All column title appears as the "windows. ... TextBox".
How can I fix this?

Thanks,

Jerry
0
Accepted
Yavor Georgiev
Telerik team
answered on 16 Jul 2010, 09:56 AM
Hello Jerry Kurata,

 You need to handle the ElementExporting event of the RadGridView:

private void radGridView1_ElementExporting(object sender, GridViewElementExportingEventArgs e)
{
    if (e.Element == ExportElement.HeaderCell)
    {
        if (e.Value is TextBox)
        {
            e.Value = (e.Value as TextBox).Text;
        }
    }
}

Greetings,
Yavor Georgiev
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
Jerry Kurata
Top achievements
Rank 1
answered on 16 Jul 2010, 05:38 PM
Thanks!  That fixed the problem.
Tags
GridView
Asked by
Jerry Kurata
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Jerry Kurata
Top achievements
Rank 1
Share this question
or