GridGroupingControl : Image in header causes invalid background.

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?

Thanks,
-jv

5 Replies

JJ Jisha Joy Syncfusion Team May 6, 2010 04:39 AM UTC

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.

http://help.syncfusion.com/samples/Grid.Windows/GGC46621.zip

Regards,
Jisha


JV Jeff Voigt May 7, 2010 07:32 PM UTC

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..

http://screensnapr.com/u/oizy7i.png


JV Jeff Voigt May 7, 2010 07:50 PM UTC

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??


JV Jeff Voigt May 7, 2010 08:18 PM UTC

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;
GTCommonLookAndFeel.DrawImage(
e.Inner.Graphics,
e.Inner.Style.BackgroundImage,
targetRectangle,
false);
}
}


JJ Jisha Joy Syncfusion Team May 10, 2010 05:08 AM UTC

Hi Jeff,

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

Regards,
Jisha

Loader.
Up arrow icon