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

change the font of all parts radgridview

8 Answers 975 Views
GridView
This is a migrated thread and some comments may be shown as answers.
mohammad
Top achievements
Rank 1
mohammad asked on 15 Mar 2013, 06:37 AM
Do you want to change the font of all parts radgridview
If you can change the font of all the controls are pretty good
example

8 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 Mar 2013, 07:03 AM
HI,

You can format the cells in CellFormatting event as shown below.
c#;
Font f = new Font(new FontFamily("Arial"), 24.0f);
private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    e.CellElement.Font = f;
}

Thanks,
Shinu
0
mohammad
Top achievements
Rank 1
answered on 15 Mar 2013, 10:38 AM
I want to change the parts that I have shown in the picture
0
Stefan
Telerik team
answered on 19 Mar 2013, 01:14 PM
Hi Mohammad,

Thank you for writing.

To change the menu items font, you can use the FilterPopupRequired event or the FilterPopupInitialized event, while for the conditional formatting form, you should use the ConditionalFormattingFormShown event. In both cases, you have to recursively iterate the items/controls and set their font:
Font f = new Font("Arial", 8);
void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e)
{
    BaseFilterPopup popup = (BaseFilterPopup)e.FilterPopup;
    SetMenuFont(popup.Items);
    popup.Font = f;
}
 
private void SetMenuFont(Telerik.WinControls.RadItemOwnerCollection radItemOwnerCollection)
{
    foreach (RadMenuItemBase item in radItemOwnerCollection)
    {
        item.Font = f;
        if (item.HasChildren)
        {
            SetMenuFont(item.Items);
        }
    }
}
 
void radGridView1_ConditionalFormattingFormShown(object sender, EventArgs e)
{
    ConditionalFormattingForm form = (ConditionalFormattingForm)sender;
    SetFormFont(form.Controls);
}
 
private void SetFormFont(Control.ControlCollection controls)
{
    foreach (Control c in controls)
    {
        c.Font = f;
        if (c.HasChildren)
        {
            SetFormFont(c.Controls);
        }
    }
}

i hope this helps.
 

Regards,
Stefan
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
hard7
Top achievements
Rank 1
answered on 13 Sep 2017, 02:37 AM

Hello, I want to change fonts for the first row of the grid which shows grouping information. I have attached an image. Please help.

Thank you.

0
Dimitar
Telerik team
answered on 13 Sep 2017, 05:15 AM
Hi,

You need to use the ViewCellFormatting event. The following article shows how you can access the group row: Formatting Group Rows | RadGridView.

I hope this will be useful. 

Regards,
Dimitar
Progress Telerik
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.
0
hard7
Top achievements
Rank 1
answered on 13 Sep 2017, 02:42 PM

Hello Dimitar,

    Thank you so much for your reply. But as you can see in the below attached picture, I have already applied style and fonts to group row but I want to change the fonts of the very first row, which shows grouped column names.

Thank you.

0
Dimitar
Telerik team
answered on 14 Sep 2017, 08:00 AM
Hi Hardik,

You can use the following approach to change this font:
private void RadButton1_Click(object sender, EventArgs e)
{
    var font = new Font("Segoe Script", 12, FontStyle.Regular);
    var elements = radGridView1.GridViewElement.GroupPanelElement.EnumDescendants(Telerik.WinControls.TreeTraversalMode.BreadthFirst);
    foreach (var item in elements)
    {
        if (item is GroupFieldElement)
        {
           ((GroupFieldElement)item).Font = font;
        }
    }
}

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik
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.
0
hard7
Top achievements
Rank 1
answered on 25 Nov 2017, 03:23 AM
Thank you so much Dimitar. It works perfectly. Thank you so much for your support.
Tags
GridView
Asked by
mohammad
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
mohammad
Top achievements
Rank 1
Stefan
Telerik team
hard7
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or