How to disable focus on grid cells in WinForms GridGroupingControl?
Disable the focus on grid cells
To disable the focus on the cells for making the read-only grid cells, you can cancel the TableControlCurrentCellActivating event in WinForms GridGroupingControl.
In the following code example, the focus is disabled only on the record cells as you can apply filtering even when the Grid is ReadOnly.
C#
//disables the focus on the RecordFieldCell void gridGroupingControl1_TableControlCurrentCellActivating(object sender, GridTableControlCurrentCellActivatingEventArgs e) { GridTableCellStyleInfo style = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex); if(style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell) { e.Inner.Cancel = true; } }
VB
'disables the focus on the RecordFieldCell Private Sub gridGroupingControl1_TableControlCurrentCellActivating(ByVal sender As Object, ByVal e As GridTableControlCurrentCellActivatingEventArgs) Dim style As GridTableCellStyleInfo = Me.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex) If style.TableCellIdentity.TableCellType = GridTableCellType.RecordFieldCell OrElse style.TableCellIdentity.TableCellType = GridTableCellType.AlternateRecordFieldCell Then e.Inner.Cancel = True End If End Sub
After applying the properties, the Grid is displayed as follows.
Figure 1: Read only Grid
Conclusion
I hope you enjoyed learning about how to disable the focus on grid cells event 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 forums, Direct-Trac, or feedback portal. We are always happy to assist you!