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

Programmatically changing font header row

2 Answers 133 Views
GridView
This is a migrated thread and some comments may be shown as answers.
IT Development
Top achievements
Rank 1
IT Development asked on 24 Jun 2009, 08:10 AM

Hello,

I need to change the font of the gridview + header Programmatically.
The gridview rows I can change successively in the cellformating event  

  private void radGridViewProductie_CellFormatting(object sender, CellFormattingEventArgs e)
{
            e.CellElement.Font = Mo.LetterType;
}


The header row i change after binding the gridview.
See the following code

schrapViewBindingSource.DataSource = Schraplijst;
radGridViewProductie.DataSource = schrapViewBindingSource;
radGridViewProductie.MasterGridViewTemplate.BestFitColumns();

GridViewRowInfo Row = this.radGridViewProductie.MasterGridViewInfo.TableHeaderRow;
foreach (GridViewCellInfo gi in Row.Cells)
{
   if (gi.CellElement != null)
   {
       gi.CellElement.Font = Mo.LetterType;
   }
}

This works but the problem is when I comment out the BestFitColumns the Cellelement always returns null

What is the best way to change the font of the header row.?
Wich event can I use for that ?


Greetings Tim

2 Answers, 1 is accepted

Sort by
0
Accepted
Jack
Telerik team
answered on 24 Jun 2009, 11:14 AM
Hello Tim,

It is safe to access cell elements only when handling CellFormatting and ViewCellFormatting events. The CellFormatting event is fired only for data cells. The ViewCellFormatting event instead fires for all cell types. So, you should handle this event. If you need further assistance, please write us back.

Best wishes,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
IT Development
Top achievements
Rank 1
answered on 24 Jun 2009, 02:53 PM
Hello Jack,

Thanks tor the reply.
it solved my problem.

Kind regards,
Tim
Tags
GridView
Asked by
IT Development
Top achievements
Rank 1
Answers by
Jack
Telerik team
IT Development
Top achievements
Rank 1
Share this question
or