Change font style of individual cells

4 posts, 1 answers
  1. Shaolin
    Shaolin avatar
    2 posts
    Member since:
    May 2016

    Posted 12 May Link to this post

    Hi All,

    Is there a easy way to change font style, e.g. Bold and Italic, for individual cells at the runtime?

    Thanks,

    Shaolin

  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 13 May Link to this post

    Hello Shaolin,

    Thank you for writing.

    In order to customize the grid cells, it is appropriate to use the CellFormatting event. The following help article demonstrates a sample approach: http://docs.telerik.com/devtools/winforms/virtualgrid/cells/formatting-data-cells

    I hope this information helps. Should you have further questions I would be glad to help.

     Regards,
    Dess
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Shaolin
    Shaolin avatar
    2 posts
    Member since:
    May 2016

    Posted 13 May in reply to Dess Link to this post

    Hi Dess,

    The issue is that I can only change Font property by using CellFormatting event. What I need is change styles of the font and I do not want to create a font for individual cell. Is there a way to set a font for all cells in a column?

    Regards,

    Shaolin

  5. Answer
    Dess
    Admin
    Dess avatar
    1609 posts

    Posted 17 May Link to this post

    Hello Shaolin,

    Thank you for writing back. 

    You can't assign the font for a column by setting a given property. The CellFormatting event is the appropriate place to assign a specific font to the desired column:
    Font f = new Font("Arial", 12f, FontStyle.Italic);
     
    private void radVirtualGrid1_CellFormatting(object sender, Telerik.WinControls.UI.VirtualGridCellElementEventArgs e)
    {
        if (e.CellElement.ColumnIndex == 3)
        {
            e.CellElement.Font = f;
        }
        else
        {
            e.CellElement.ResetValue(LightVisualElement.FontProperty, ValueResetFlags.Local);
        }
    }

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top