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.

GridGroupingControl : Image in header causes invalid background.

Thread ID:





94241 Apr 30,2010 08:56 AM May 10,2010 01:08 AM Windows Forms 5
Tags: GridControl
Jeff Voigt
Asked On April 30, 2010 08:56 AM

All I'm trying to do is replace the text of a header column with an Icon. I set the CellType = "Image" and set the Image properties according (I even tried using the BackgroundImage properties) and the end result was that the Image displayed but the background was a solid Grey.

I have the grid set to render using the Office2007-Blue look and I'm running on Windows7 x64 bit.

Am I missing something?


Jisha Joy [Syncfusion]
Replied On May 6, 2010 12:39 AM

Hi Jeff,

You need to handle QueryCellStyleInfo, TableControl.MouseMove event to achieve the desired behavior. Please refer the following sample that implement the same when a checkbox is placed in the Column header.



Jeff Voigt
Replied On May 7, 2010 03:32 PM

Well that example shows me how I can catch the info on the mouse and how to apply a brush.

The only problem is that it does not match the hovering brush that is used for the rest of the application....

take a look at this screenshot to see. The icon header is a bit too dark..


Jeff Voigt
Replied On May 7, 2010 03:50 PM

In all honesty it is a poor solution. I'm loosing all of the other drawing capabilities such as the up/down arrow for sorting.. mouse help down (has different interior).. all of that is lost.

A better solution is to make the cell type act as though it is a header cell type and just put some custom drawing to put the image in it..

Does that exist? How can I do that.. I would much rather do an additive to the other features a header cell gives you then trying to replicate all of the features with the base image cell type =(

Why doesn't the grid support an image in the header??

Jeff Voigt
Replied On May 7, 2010 04:18 PM

Here is my solution:

private void GTGridGrouping_TableControlDrawCellBackground(object sender, GridTableControlDrawCellBackgroundEventArgs e)
if (e.Inner.Style.CellType == "ColumnHeaderCell" && e.Inner.Style.BackgroundImage != null)
e.Inner.Cancel = true;

private void GTGridGrouping_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
if (e.Inner.Style.CellType == "ColumnHeaderCell" && e.Inner.Style.BackgroundImage != null)
Rectangle targetRectangle = e.Inner.TextRectangle;
targetRectangle.X = targetRectangle.X + ((targetRectangle.Width / 2) - (16 / 2));
targetRectangle.Y = targetRectangle.Y + ((targetRectangle.Height / 2) - (16 / 2));
targetRectangle.Width = 16;
targetRectangle.Height = 16;

Jisha Joy [Syncfusion]
Replied On May 10, 2010 01:08 AM

Hi Jeff,

Thank you for your update. Glad to know that issue got resolved.



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.