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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ColorEdit on GDBG

Thread ID:





80697 Apr 22,2009 11:56 PM UTC Apr 23,2009 02:25 PM UTC WinForms 1
Tags: GridControl
Peter Trevor
Asked On April 22, 2009 11:56 PM UTC

Hi. I’m using the GDBG with several columns, one is set to type “ColorEdit”. I want to display only the colour in the cell and not the name or any other text. It mostly works but with two exceptions.

1) In the PrepareViewStyleInfo event I have...

if (e.RowIndex > 0)
if (e.ColIndex == COLOUR_COLUMN) e.Style.TextColor = Color.FromName(e.Style.Text);

... which hides the text. However, after the colour is changed but before the user leaves the row the name of the colour is visible. Is there an earlier event I can use that fires immediately after the colour is changed?

2) But more importantly, even though it is hidden the text can still be edited/corrupted by the user. How do I prevent this? (I only want to accept button clicks for this column.)

(Using ES2009v1 with VS2005)

Rajadurai C [Syncfusion]
Replied On April 23, 2009 02:25 PM UTC

Hi Pedro,

Thanks for your interest in Syncfusion products.

1) To hide the text from the user, you can make use of TextMargins property. Please refer to the following code which hides text from the user.

ColorConverter cc = new ColorConverter();
void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
if (e.RowIndex > 0 && e.ColIndex == 1)
int height = this.gridDataBoundGrid1.Model.RowHeights[e.RowIndex];
e.Style.CellType = "ColorEdit";
e.Style.BackColor = (Color)cc.ConvertFromString(e.Style.CellValue.ToString());
e.Style.TextMargins.Top = height / 2;
e.Style.TextMargins.Bottom = height / 2;

2) If you want to prevent the users from editing the textbox part of ColorEdit cell, set the renderer' EditPart' Enabled property to false. Please refer to the following code.

GridDropDownColorUICellRenderer rend = this.gridDataBoundGrid1.CellRenderers["ColorEdit"] as GridDropDownColorUICellRenderer;
rend.EditPart.Enabled = false;



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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon