How to restrict the editing option of the grid cell in WinForms GridGroupingControl?
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 its
content.
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 = FalseUsing 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.
AddHandler 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 SubUsing 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
AddHandler 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 SubSamples: