change the font of all parts radgridview

9 posts, 0 answers
  1. mohammad
    mohammad avatar
    10 posts
    Member since:
    Mar 2009

    Posted 15 Mar 2013 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 15 Mar 2013 Link to this post

    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
  3. mohammad
    mohammad avatar
    10 posts
    Member since:
    Mar 2009

    Posted 15 Mar 2013 Link to this post

    I want to change the parts that I have shown in the picture
  4. Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 19 Mar 2013 Link to this post

    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.
  5. hard7
    hard7 avatar
    3 posts
    Member since:
    Sep 2017

    Posted 12 Sep 2017 in reply to Stefan Link to this post

    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.

  6. Dimitar
    Admin
    Dimitar avatar
    2514 posts

    Posted 13 Sep 2017 Link to this post

    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.
  7. hard7
    hard7 avatar
    3 posts
    Member since:
    Sep 2017

    Posted 13 Sep 2017 in reply to Dimitar Link to this post

    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.

  8. Dimitar
    Admin
    Dimitar avatar
    2514 posts

    Posted 14 Sep 2017 Link to this post

    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.
  9. hard7
    hard7 avatar
    3 posts
    Member since:
    Sep 2017

    Posted 24 Nov 2017 in reply to Dimitar Link to this post

    Thank you so much Dimitar. It works perfectly. Thank you so much for your support.
Back to Top