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 set style properties for Read-Only cells in WinForms GridControl?

Platform: WinForms |
Control: GridControl
Tags: styling, readonly

Style property for read-only cells in grid

Setting a cell as ReadOnly enables ReadOnly for programmatic changes. Hence a cell set to ReadOnly cannot have any property changed (Text, BackColor, Font, ReadOnly) unless you specify to ignore the ReadOnly flag. To change a ReadOnly cell, you need to set grid.IgnoreReadOnly as true. Make necessary changes and then reset the IgnoreReadOnly property. Programmatically changing a cell value triggers the same change events that are triggered that means one event can handle the saving of all changes.


//To make the cells readonly
this.gridControl1.TableStyle.Text = "Test";
this.gridControl1.TableStyle.BackColor = Color.LightPink;
this.gridControl1.TableStyle.ReadOnly = true;
this.gridControl1.TableStyle.Font.Bold = true;
//Free the cells from readonly
this.gridControl1.Model.IgnoreReadOnly = true;
this.gridControl1.TableStyle.Text = "Changed";
this.gridControl1.TableStyle.BackColor = Color.LightGreen;
this.gridControl1.TableStyle.Font.Bold = true;
//if you want to make it to read only again, reset the IgnoreReadOnly property.
this.gridControl1.Model.IgnoreReadOnly = false;



'To make the cells readonly
Me.gridControl1.TableStyle.Text = "Test"
Me.gridControl1.TableStyle.BackColor = Color.LightPink
Me.gridControl1.TableStyle.ReadOnly = True
Me.gridControl1.TableStyle.Font.Bold = True
'Free the cells from readonly
Me.gridControl1.Model.IgnoreReadOnly = True
Me.gridControl1.TableStyle.Text = "Changed"
Me.gridControl1.TableStyle.BackColor = Color.LightGreen
Me.gridControl1.TableStyle.Font.Bold = True
'if you want to make it to read only again, reset the IgnoreReadOnly property.
Me.gridControl1.Model.IgnoreReadOnly = False



C#: ReadOnlyCell

VB: ReadOnlyCell

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment
Ly Ca Tieu
May 30, 2017
Hi all! Please help me! How to set the color for the cell not to edit in the gridGroupingControl1_TableControlCurrentCellStartEditing event of the grouping control. If it was, for me an example tool! Thanks Reply

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