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
close icon

multi-color column header

I'm using a GridDataBoundGrid and would like to change the column header text to display in more than one color.

For example, if the column header was "* Plan ID", I want "*" to be red while "Plan ID" is black.

Any ideas? Thanks.

5 Replies

HA haneefm Syncfusion Team July 23, 2007 08:27 PM UTC

Hi Eddie,

You can do this by handling the DrawCell event of the grid and set e.Cancel to true to customize your drawing in a grid cell. Below is a code snippet that show this task.

void gridDrawCell(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellEventArgs e)
{
if (e.ColIndex == 2 && e.RowIndex == 0)
{
e.Cancel = true;
e.Renderer.Draw(e.Graphics, e.Bounds, e.RowIndex, e.ColIndex, e.Style);
e.Graphics.DrawString("**", e.Style.GdipFont, new SolidBrush(Color.Red), e.Bounds);
}
}

Best regards,
Haneef


EJ Eddie Jones July 23, 2007 09:51 PM UTC

Great customer service as usual. Thanks.


EJ Eddie Jones July 23, 2007 10:00 PM UTC

One other thing -- when I hover over the column header with the mouse, the asterisk disappears.


HA haneefm Syncfusion Team July 23, 2007 10:33 PM UTC

Hi Eddie,

Thank you for your update.

I am afraid that i was not able to reproduce the issue in your sample. Also i have created a simple sample to test this issue and it is available in the following link,.

Sample : GDBGHeaderDrawing.zip

Please have a look at the above sample and if still the issue exists, could you please try reproducing it in the above sample or send us the reproducing steps that we could sort out the cause of the issue and provide you a solution?

Best regards,
Haneef


EJ Eddie Jones July 24, 2007 07:53 PM UTC

Thanks, Haneef.

I got it working. I had the order of the DrawString and Draw methods reversed.

Loader.
Live Chat Icon For mobile
Up arrow icon