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

Grid font is too small

1 Answer 142 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 2
Michael asked on 21 Apr 2009, 11:28 PM
I'm finding that the Grid doesn't use the font of its parent for the column headers and cells.  Is there a way to cause it to do so?

1 Answer, 1 is accepted

Sort by
0
Accepted
Mike
Telerik team
answered on 22 Apr 2009, 01:38 PM
Hi Michael,

Generally any Font setting in a RadControl can be defined through theme. This breaks the inheritance with any of the Parent RadElement and eventually Control's parent. Note that RadElements support property value inheritance for some properties like Font, ForeColor, BackColor. This feature resembles controls' ambient properties. RootElement inherits its properties from the corresponding RadControl properties. In the case of RadGridView, header cell's Font would not inherit any values, since it is set through theme.

You can test where any property of any RadElement gets its value from, using RadControlSpy, by right-clicking the property name in the property grid:

RadControl Spy

The easiest solution in the case wth RadGridView header (or any other cells) would be to set the Font you need in the ViewCellFormatiing event:
private void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e) 
    if (e.CellElement is GridHeaderCellElement) 
    { 
        e.CellElement.Font = this.Font; 
    } 
(assuming "this" is the form).

If the you need the font to change dynamically (if form's font changes) you should though update the header row:
this.radGridView1.MasterGridViewInfo.TableHeaderRow.InvalidateRow(); 

I have attached a sample that demonstrates the approach:

demo application

Regards,
Mike
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.
Tags
GridView
Asked by
Michael
Top achievements
Rank 2
Answers by
Mike
Telerik team
Share this question
or