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

ColorEdit and Transparent color

Hi, I''ve got a grid with a ColorEdit cell. If the user selects the Transparent colour from the ColorEdit it throws an "This control does not support transparent background colors." exception. Is there a way to either (a) allow the ColorEdit to select Transparent (preferable); or (b) remove invalid colours from the ColorEdit colour list? You can duplicate this problem by running the CellStyles sample, changing a cell to ColorEdit cell type, then in the cell selecting Transparent. Thanks, Sue

1 Reply

AD Administrator Syncfusion Team June 23, 2005 12:59 AM UTC

The reason this is happening is the the control in the cell is derived from TextBoxBase, and this WindowsForms control does not accept Transparent colors with its default settings. You can try directly calling Control.SetStyles through reflection to change this setting. (This method is protected, so you cannot directly call it.
GridDropDownColorUICellRenderer cr = this.gridControl1.CellRenderers["ColorEdit"] as GridDropDownColorUICellRenderer;
TextBoxBase ui = cr.TextBox;
System.Reflection.MethodInfo mInfo = typeof(Control).GetMethod("SetStyle", 
	System.Reflection.BindingFlags.Instance | 
	System.Reflection.BindingFlags.InvokeMethod | 
	System.Reflection.BindingFlags.NonPublic);
if(mInfo != null)
{
	mInfo.Invoke(ui, new object[]{ControlStyles.SupportsTransparentBackColor, true});
}

Loader.
Live Chat Icon For mobile
Up arrow icon