We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to change a cell’s font to a particular font family in WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: December 18, 2019
Tags: styling

Font settings

To change a cell’s font, use the FaceName property of the font object for that cell. A cell’s font object is given by the font property of the cell’s style.

 

By using GridModel

C#

//Set the particular fontfamily for the particular cell.
gridControl1[2,5].Font.Facename = "Arial";
gridControl1[2,5].Font.Bold = true;
gridControl1[2, 5].Font.Size = 9;
gridControl1[2, 5].Text = "Enjoy";

 

VB

'Set the particular fontfamily for the particular cell.
gridControl1(2,5).Font.Facename = "Arial"
gridControl1(2,5).Font.Bold = True
gridControl1(2, 5).Font.Size = 9
gridControl1(2, 5).Text = "Enjoy"

 

By using QueryCellInfo Event

C#

void gridControl1_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
{
 if (e.RowIndex > 0 && e.ColIndex > 0)
  e.Style.Text = "Enjoy";
  //Set the particular fontfamily for the particular cell.
  if (e.RowIndex == 2 && e.ColIndex == 3)
  {
   e.Style.Font.Facename = "Arial";
   e.Style.Font.Bold = true;
   e.Style.Font.Size = 9;
  }
}

 

VB

Private Sub gridControl1_QueryCellInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs)
 If e.RowIndex > 0 AndAlso e.ColIndex > 0 Then
  e.Style.Text = "Enjoy"
 End If
 'Set the particular fontfamily for the particular cell.
 If e.RowIndex = 2 AndAlso e.ColIndex = 3 Then
  e.Style.Font.Facename = "Arial"
  e.Style.Font.Bold = True
  e.Style.Font.Size = 9
 End If
End Sub

 

After applying the properties, the grid cell is displayed as follows:

Shows the change font family in grid cell

Samples:

C#: Changing the_fontfamily

VB: Changing the_fontfamily

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon