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 make 'CTRL+~', shortcut key, to show formulas instead of values similar to Excel in the WinForms GridControl?

Platform: WinForms |
Control: GridControl

Show the formulas instead of values in grid

This can be done by handling the GridControl's KeyDown and DrawCellDisplayText event. A flag can be used to synchronize the KeyDown event and the DrawCellDisplayText for displaying the formula.


this.gridControl1.KeyDown += gridControl1_KeyDown;
//set the cellType as FormulaCell
this.gridControl1.TableStyle.CellType = GridCellTypeName.FormulaCell;
this.gridControl1.DrawCellDisplayText += gridControl1_DrawCellDisplayText;
void gridControl1_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
    if (this.gridControl1[e.Style.CellIdentity.RowIndex, e.Style.CellIdentity.ColIndex].CellType == "FormulaCell" & flag)
        //draw the display text for the cell
        e.DisplayText = e.Style.CellValue.ToString();
void gridControl1_KeyDown(object sender, KeyEventArgs e)
    bool keydown = (e.Modifiers & Keys.Control) != Keys.None;
    Keys Key = e.KeyCode & Keys.KeyCode;
    //check whether the pressed key is Control with tilde or not
    if (Key == Keys.Oemtilde && keydown)
        flag = !flag;


Private Me.gridControl1.KeyDown += AddressOf gridControl1_KeyDown
'set the cellType as FormulaCell
Me.gridControl1.TableStyle.CellType = GridCellTypeName.FormulaCell
AddHandler Me.gridControl1.DrawCellDisplayText, AddressOf gridControl1_DrawCellDisplayText
void gridControl1_DrawCellDisplayText(Object sender, GridDrawCellDisplayTextEventArgs e)
    If Me.gridControl1(e.Style.CellIdentity.RowIndex, e.Style.CellIdentity.ColIndex).CellType Is "FormulaCell" & flag Then
        'draw the display text for the cell
        e.DisplayText = e.Style.CellValue.ToString()
    End If
void gridControl1_KeyDown(Object sender, KeyEventArgs e)
    Dim keydown As Boolean = (e.Modifiers And Keys.Control) <> Keys.None
    Dim Key As Keys = e.KeyCode And Keys.KeyCode
    'check whether the pressed key is Control with tilde or not
    If Key = Keys.Oemtilde AndAlso keydown Then
        flag = Not flag
    End If



C#: Showing_Formulas

VB: Showing_Formulas

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