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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Change Font Color of Rows

Thread ID:

Created:

Updated:

Platform:

Replies:

62813 Jun 22,2007 11:31 AM UTC Jun 22,2007 05:33 PM UTC WinForms 1
loading
Tags: GridControl
Raul
Asked On June 22, 2007 11:31 AM UTC

Hi,

I would want to change the Font Color of Specific rows depending on some condition, The code I am using is as follows :

private void dgrdCato_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex > 0)
{
if (dgrdCato[e.RowIndex, 6].Text.ToString().Equals("Active"))
e.Style.TextColor = Color.Green;
else
e.Style.TextColor = Color.Red;
dgrdCato.RefreshRange(GridRangeInfo.Row(e.RowIndex));
}
}

However the above is not working, kindly help.

Rajagopal [Syncfusion]
Replied On June 22, 2007 05:33 PM UTC

Hi Raul,

You need to catch the PrepareViewStyleInfo event of the grid to do this. In the event handler, you need to check your condition based on e.RowIndex and e.ColIndex, and then conditionally set e.Style.TextColor.

void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex > 0 && e.ColIndex > 0)
{
if (e.Style.Text == "Active")
e.Style.TextColor = Color.Green;
else
e.Style.TextColor = Color.Red;
}
}

Let us know if you need any further help.
Regards,
Rajagopal

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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

;