How to enable or disable the editing a record based on the value of a unbound column in WinForms GridGroupingControl?
Enable or disable the editing record
In WinForms GridGroupingControl, you can enable or disable the editing a record based on the value of unbound column by subscribing the TableControlCurrentCellStartEditing event and setting the Inner.Cancel property of event argument.
For example, in the below code snippet, Records can be retrieved through the GetRecord() method and disable the editing based on the unbound column’s value by setting the Cancel property as true.
C#
//For handling the editing of the cells this.gridGroupingControl1.TableControlCurrentCellStartEditing += gridGroupingControl1_TableControlCurrentCellStartEditing; void gridGroupingControl1_TableControlCurrentCellStartEditing(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCancelEventArgs e) { GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex); if (style.TableCellIdentity.Column.Name != "UnboundColumnName") { Record record =style.TableCellIdentity.DisplayElement.GetRecord(); if (record.GetValue("UnboundColumnName ").ToString() != "0") { //Cancel the editing for the record values e.Inner.Cancel = true; } } }
VB
'For handling the editing of the cells AddHandler Me.gridGroupingControl1.TableControlCurrentCellStartEditing, AddressOf gridGroupingControl1_TableControlCurrentCellStartEditing void gridGroupingControl1_TableControlCurrentCellStartEditing(Object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCancelEventArgs e) Dim style As GridTableCellStyleInfo = e.TableControl.GetTableViewStyleInfo(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex) If style.TableCellIdentity.Column.Name <> " UnboundColumnName" Then Dim record As Record =style.TableCellIdentity.DisplayElement.GetRecord() If record.GetValue("UnboundColumnName").ToString() <> "0" Then 'Cancel the editing for the record values e.Inner.Cancel = True End If End If
Enable the editing a record based on the value of a unbound column :Disable the editing a record based on the value of a unbound column :
Samples:
C#: RadioButton_UnBoundColumn_CS
VB: RadioButton_UnBoundColumn_VB
Conclusion
I hope you enjoyed learning about how to enable or disable the editing a record based on the value of a unbound column in WinForms GridGroupingControl.
You can refer to our WinForms GridGroupingControl’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridGroupingControl documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms 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 WinForms GridGroupingControl and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!