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

GridGroupingControl BackColor Transparency Problem

I''ve been trying to get the GridGroupingControl in v4.2 to work correctly with colors.

For what ever reason, the GGC does not take the parents back color when it is added to a ControlCollection. Instead it defaults to SystemColors.Window This means that no matter what I do, I can''t get the GGC to take on the parent''s backColor.

The only way to make it work properly is to override OnParentChanged, and set the BackColor in there.

This has the interesting side effect of making OnBackColorChanged called twice, once from setting the backcolor in OnParentChanged once from the private method AssignParent(defined in Control). In the included example, you can this when commenting and uncommenting the line "BackColor = Parent.BackColor" in MyGGC.cs

Grid14.zip

6 Replies

AD Administrator Syncfusion Team October 12, 2006 08:28 PM UTC

Hi Matthew,

Please refer this forum thread
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=50153

Let us know if this helps.
Thanks,
Rajagopal


AD Administrator Syncfusion Team October 13, 2006 10:15 AM UTC

It doesn''t work. The back color never gets changed from Color.Window to the BackColor of the containing control.

This isn''t so much about transparency as it is about the GGC taking on the color of the parent control like it should normally.

>Hi Matthew,

Please refer this forum thread
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=50153

Let'>http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=50153''>http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=50153

Let us know if this helps.
Thanks,
Rajagopal


AD Administrator Syncfusion Team October 16, 2006 05:47 AM UTC

Hi Matthew,

There is no built-in support for this. But you can derive the GridGroupingControl and override the OnParentBackColorChanged method to enable this. Below is a code snippet

public class MyGGC : GridGroupingControl
{
public MyGGC()
{}
protected override void OnParentBackColorChanged(EventArgs e)
{ base.OnParentBackColorChanged (e);
BackColor = Parent.BackColor; }
}

Let me know if this works.

Best Regards,
Haneef


AD Administrator Syncfusion Team October 16, 2006 01:06 PM UTC

This works, but is a rather ugly hack considering that when deriving from a control you get this behavior for free. Why was behavior overridden?


AD Administrator Syncfusion Team October 17, 2006 01:05 PM UTC

Hi Matthew,

I have consulted the development team regarding this issue and will let you know the details on this soon.

Thanks for your patience.

Best Regards,
Haneef


AD Administrator Syncfusion Team October 18, 2006 01:46 PM UTC

Hi Matthew,

To make the GridGroupingControl reset its backcolor (and hence inherit the backcolor of its parent) by calling,
this.gridGroupingControl1.ResetBackColor();

So, you can make it inherit the color without deriving anything. (Note, the ResetBackColor method is inherited from Control and does not show up in intellisense, but it is valid.)

The reason the gridgroupingcontrol forces the backcolor is to prevent the default grid from showing cells with SystemColors.Control as their backcolors, since this would not be the desired color as default by the users.

Thanks,
Rajagopal


Loader.
Live Chat Icon For mobile
Up arrow icon