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

Change font style of individual cells

3 Answers 178 Views
VirtualGrid
This is a migrated thread and some comments may be shown as answers.
Shaolin
Top achievements
Rank 1
Shaolin asked on 12 May 2016, 08:37 PM

Hi All,

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

Thanks,

Shaolin

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 May 2016, 05:17 AM
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 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.
0
Shaolin
Top achievements
Rank 1
answered on 13 May 2016, 12:34 PM

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

0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 May 2016, 06:43 AM
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.
Tags
VirtualGrid
Asked by
Shaolin
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Shaolin
Top achievements
Rank 1
Share this question
or