Articles in this section
Category / Section

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

3 mins read

Font settings

To change a cell’s font in WinForms GridControl, 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

 

 

Conclusion

I hope you enjoyed learning about how to change a cell’s font to a particular font family in WinForms GridControl.

You can refer to our WinForms GridControl’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridControl documentation to understand how to present and manipulate data.


For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms Grid Control and other WinForms components.


If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied