Articles in this section
Category / Section

How to make a grid cell as read-only in WinForms GridGroupingControl?

1 min read

Make grid cell as read-only

To make a grid cell as read-only, without having the cursor while clicking on the cell, you can cancel the TableControlCurrentCellStartEditing event. In the following code, the cursor is disabled when you click on the RecordFieldCell in the WinForms GridGroupingControl.

C#

this.gridGroupingControl1.TableControlCurrentCellStartEditing += gridGroupingControl1_TableControlCurrentCellStartEditing;
//Disable Record rows being edited and disables blinking cursor inside the cell.
void gridGroupingControl1_TableControlCurrentCellStartEditing(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCancelEventArgs e)
{
    GridTableCellStyleInfo style = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex);
    if(style.TableCellIdentity.TableCellType==GridTableCellType.RecordFieldCell || style.TableCellIdentity.TableCellType==GridTableCellType.AlternateRecordFieldCell)
    {
        e.Inner.Cancel = true;
    }
}

VB

Private Me.gridGroupingControl1.TableControlCurrentCellStartEditing += AddressOf gridGroupingControl1_TableControlCurrentCellStartEditing
'Disable Record rows being edited and disables blinking cursor inside the cell.
Private Sub gridGroupingControl1_TableControlCurrentCellStartEditing(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCancelEventArgs)
   Dim style As GridTableCellStyleInfo = Me.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex)
   If style.TableCellIdentity.TableCellType=GridTableCellType.RecordFieldCell OrElse style.TableCellIdentity.TableCellType=GridTableCellType.AlternateRecordFieldCell Then
     e.Inner.Cancel = True
   End If
End Sub

 

Note:

When you are using the browse only property, you can achieve the same behavior but you cannot apply filtering to the grid.

Samples:

C#: Read-only

VB: Read-only



Conclusion

I hope you enjoyed learning about how to make a grid cell as read-only in WinForms GridGroupingControl.

You can refer to our WinForms GridGroupingControl feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridGroupingControl documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please sign in to leave a comment
Access denied
Access denied