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 get the RGB value when a color is selected in the ColorEdit cell in WinForms GridControl?

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

GridControl with ColorEdit cell

You can obtain the selected color from Renderer.ControlValue of the current cell in CurrentCellCloseDropDown event handler.


private void Form1_Load(object sender, EventArgs e)
    this.gridControl1.ColWidths[3] = 100;
    //Set cell type as ColorEdit cell
    this.gridControl1[3, 3].CellType = "ColorEdit";
    this.gridControl1[3, 3].CellValueType = typeof(Color);
    this.gridControl1[3, 3].CellValue = "Blue";
    this.gridControl1.CurrentCellCloseDropDown += gridControl1_CurrentCellCloseDropDown;
void gridControl1_CurrentCellCloseDropDown(object sender, PopupClosedEventArgs e)
      //Get Grid's CurrentCell
     GridCurrentCell cc = this.gridControl1.CurrentCell;
     if (cc.Renderer is GridDropDownColorUICellRenderer)
         //Convert CurrentCell control value to Color
        Color c = (Color)cc.Renderer.ControlValue;


Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
    Me.gridControl1.ColWidths(3) = 100
    'Set cell type as ColorEdit cell
    Me.gridControl1(3, 3).CellType = "ColorEdit"
    Me.gridControl1(3, 3).CellValueType = GetType(Color)
    Me.gridControl1(3, 3).CellValue = "Blue"
    AddHandler Me.gridControl1.CurrentCellCloseDropDown, AddressOf      gridControl1_CurrentCellCloseDropDown
End Sub
Private Sub gridControl1_CurrentCellCloseDropDown(ByVal sender As Object, ByVal e As PopupClosedEventArgs)
     'Get Grid's CurrentCell
    Dim cc As GridCurrentCell = Me.gridControl1.CurrentCell
    If TypeOf cc.Renderer Is GridDropDownColorUICellRenderer Then
          'Convert CurrentCell control value to Color
         Dim c As Color = CType(cc.Renderer.ControlValue, Color)
         Console.WriteLine("R-Val:" & c.R)
         Console.WriteLine("G-Val:" & c.G)
         Console.WriteLine("B-Val:" & c.B)
    End If
End Sub

The following screenshot displays the Grid control with ColorEdit cell.

Grid control with coloredit cell

Figure 1: Grid Control with ColorEdit Cell

The following is the output screenshot.

Show the RGB value

Figure 2: Output screenshot


C#: GetRGBValue



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