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

How to restrict the editing option of the grid cell in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: May 5, 2015 |
Last Revised Date: December 24, 2019
Tags: editing

Restrict the editing option of grid

You can restrict the editing option of the current cell by using the following methods. The AllowEdit, ReadOnly and CurrentCellStartEditing event are used to disable the editing of the grid cell.

Using AllowEdit Property

By using this property, the current cell enters to the edit mode, but you cannot edit the content of it.

C#

//Disable the Editing of the table content
this.gridGroupingControl1.TableDescriptor.AllowEdit = false;

VB

'Disable the Editing of the table content
Me.gridGroupingControl1.TableDescriptor.AllowEdit = False

Using CurrentCellStartEditing Event

This event triggers while the cell is entering to the edit mode. By cancelling this event you can prevent the editing of the grid cell.

C#

//Hook this event to prevent the current cell from editing.
this.gridGroupingControl1.TableControl.CurrentCellStartEditing += TableControl_CurrentCellStartEditing;
void TableControl_CurrentCellStartEditing(object sender, CancelEventArgs e)
{
    //Cancel the editing of the current cell
    e.Cancel = true;
}

VB

'Hook this event to prevent the current cell from editing.
Private Me.gridGroupingControl1.TableControl.CurrentCellStartEditing += AddressOf TableControl_CurrentCellStartEditing
Private Sub TableControl_CurrentCellStartEditing(ByVal sender As Object, ByVal e As CancelEventArgs)
   'Cancel the editing of the current cell
   e.Cancel = True
End Sub

Using QueryCellStyleInfo Event

By setting the “ReadOnly” property value as true, you cannot change the content of the cell.

C#

//Hook the event to change the particular cell style
this.gridGroupingControl1.QueryCellStyleInfo += gridGroupingControl1_QueryCellStyleInfo;
void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
    if (e.TableCellIdentity.ColIndex == 3)
    {
        e.Style.ReadOnly = true;
    }
}

VB

'Hook the event to change the particular cell style
Private Me.gridGroupingControl1.QueryCellStyleInfo += AddressOf gridGroupingControl1_QueryCellStyleInfo
Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs)
   If e.TableCellIdentity.ColIndex = 3 Then
      e.Style.ReadOnly = True
   End If
End Sub

Samples:

C#: RestrictEditingInGGC

VB: RestrictEditingInGGC

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
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
Live Chat Icon