2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Unbound columnTo add an Unbound column in the grid, TableDescriptor. UnboundFields collection can be used and the CheckBox cell type can be assigned in the following way, C# this.gridGroupingControl1.TableDescriptor.UnboundFields.Add("print"); this.gridGroupingControl1.TableDescriptor.Columns["print"].Appearance.AnyRecordFieldCel.CellType = "CheckBox";
VB Me.gridGroupingControl1.TableDescriptor.UnboundFields.Add("print") Me.gridGroupingControl1.TableDescriptor.Columns("print").Appearance.AnyRecordFieldCel.CellType = "CheckBox"
The values of that Unbound field can be maintained through QueryValue and SaveValue events. An internal collection will be handled for displaying and updating the values. C# this.gridGroupingControl1.TableDescriptor.QueryValue += new FieldValueEventHandler(unboundField_QueryValue); private void unboundField_QueryValue(object sender, FieldValueEventArgs e) { if (e.Field.Name == "print" && checkboxvalues.Contains(e.Record.Id)) { e.Value = (bool)checkboxvalues[e.Record.Id]; } }
VB Private Me.gridGroupingControl1.TableDescriptor.QueryValue += New FieldValueEventHandler(AddressOf unboundField_QueryValue) Private Sub unboundField_QueryValue(ByVal sender As Object, ByVal e As FieldValueEventArgs) If e.Field.Name = "print" AndAlso checkboxvalues.Contains(e.Record.Id) Then e.Value = CBool(checkboxvalues(e.Record.Id)) End If End Sub
C# this.gridGroupingControl1.TableDescriptor.SaveValue += new FieldValueEventHandler(unboundField_SaveValue); private void unboundField_SaveValue(object sender, FieldValueEventArgs e) { if (e.Field.Name == "print" && checkboxvalues.Contains(e.Record.Id)) { checkboxvalues[e.Record.Id] = bool.Parse(e.Value.ToString()); } }
VB Private Me.gridGroupingControl1.TableDescriptor.SaveValue += New FieldValueEventHandler(AddressOf unboundField_SaveValue) Private Sub unboundField_SaveValue(ByVal sender As Object, ByVal e As FieldValueEventArgs) If e.Field.Name = "print" AndAlso checkboxvalues.Contains(e.Record.Id) Then checkboxvalues(e.Record.Id) = Boolean.Parse(e.Value.ToString()) End If End Sub
Screenshot
Samples: C# : CheckBox column at run time VB : CheckBox column at run time Reference link: https://help.syncfusion.com/windowsforms/classic/gridgroupingcontrol/managing-records-and-columns#unbound-columns |
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.
Hi! Can i ask something about unbound field , please!
I have one CheckBox cell type with UnboundFields collection and i use GridExcelFilter too.
The problem is when i click at checkbox , the Record is not update value immediately, so that event SaveValue is not raised. This problem make the GridExcelFilter.RecordFiltersItemChanged can not raise too. But when i click at checkbox then click on another cell , the Record update immediately , and everything is ok. So there's a little annoyance with having to click on another cell so that the record can be updated before using GridExcelFilter.
Thank you for helping me. Best Regard