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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use a ColorEdit control in a cell and retrieve its value as a color object in WinForms GridControl?

Platform: WinForms |
Control: GridControl
Tags: celltype, color

Setting ColorEdit control in a grid cell

To change a cell to ColorEdit cell, you can set the CellType to ColorEdit and the Text property to some appropriate color value. The color object can be retrieved from the ColorEdit cell by converting its type of the Text from string to Color by using the ConvertFromString() method of the TypeDescriptor.GetConverter().


//set cell type
gridControl1[2, 3].CellType = "ColorEdit";
//set initial value to Color.Aqua
gridControl1[2, 3].Text = "Aqua";
//or to set a RGB color, use something like
// gridControl1[4, 4].Text = "2, 12, 255"; //set initial value to RGB(2,12,255)....
//to retrieve a Color object from this cell, use code such as
Color c = (Color)TypeDescriptor.GetConverter(typeof(Color)).ConvertFromString(gridControl1[2,3].Text);


'set cell type
gridControl1(2, 3).CellType = "ColorEdit"
'set initial value to Color.Aqua
gridControl1(2, 3).Text = "Aqua"
'or to set a RGB color, use something like
‘gridControl1[4, 4].Text = "2, 12, 255" 'set initial value to RGB(2,12,255)...
'to retrieve a Color object from this cell, use code such as
Dim c As Color = CType(TypeDescriptor.GetConverter(GetType(Color)).ConvertFromString(gridControl1(4, 4).Text), Color)

The following screenshot illustrates the output.

CellType property set to ColorEdit

Figure 1: CellType property set to ColorEdit


C#: ColorEditCell

VB: ColorEditCell

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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

Live Chat Icon For mobile