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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set the text color that appears in the WinForms GridControl cell?

Platform: WinForms |
Control: GridControl
Tags: styling

Apply text color

The WinForms Grid Control uses the TextColor property of the cell’s style to set it to the Color value. In the given sample, the TextColor is applied for a particular row or column or cell or a range of cells.


Using GridModel


//sets the text to the particular row
gridControl1.RowStyles[3].Text = "Have";
//sets the textcolor to the particular cell
gridControl1[3, 2].TextColor = Color.Red;
//sets the textcolor for range of cells
GridStyleInfo style = new GridStyleInfo();
style.TextColor = Color.Red;
this.gridControl1.ChangeCells(GridRangeInfo.Cells(3,3,2,2), style);


'sets the text to the particular row
gridControl1.RowStyles(3).Text = "Have"
'sets the textcolor to the particular cell
gridControl1(3, 2).TextColor = Color.Red
'sets the textcolor for range of cells
Dim style As New GridStyleInfo()
style.TextColor = Color.Red
Me.gridControl1.ChangeCells(GridRangeInfo.Cells(3,3,2,2), style)


By using QueryCellInfo Event


void gridControl1_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
 //sets the text to the particular row
 if (e.RowIndex == 3 && e.ColIndex > 0)
  e.Style.Text = "Have";
 //sets the textcolor to the particular cell
 if (e.RowIndex == 3 && e.ColIndex ==2)
  e.Style.TextColor = Color.Red;



Private Sub gridControl1_QueryCellInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs)
 'sets the text to the particular row
 If e.RowIndex = 3 AndAlso e.ColIndex > 0 Then
  e.Style.Text = "Have"
 End If
 'sets the textcolor to the particular cell
 If e.RowIndex = 3 AndAlso e.ColIndex =2 Then
  e.Style.TextColor = Color.Red
 End If
End Sub


After applying the TextColor properties, the Grid is shown as follows,

Set the text color in a grid cell

Figure 1: Set the text color



C#: TextColor

VB: TextColor

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
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

Live Chat Icon For mobile