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.
Unfortunately, activation email could not send to your email. Please try again.

Change Font Color of Rows

Thread ID:

Created:

Updated:

Platform:

Replies:

62813 Jun 22,2007 07:31 AM Jun 22,2007 01:33 PM Windows Forms 1
loading
Tags: GridControl
Raul
Asked On June 22, 2007 07:31 AM

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 01:33 PM

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.

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.

;