How to group the unbound column in WinForms GridGroupingControl?
Group the unbound column
Since the unbound column data are not bound to the data source, the WinForms Grid Grouping Control of these columns are not possible. In order to group the unbound column, the unbound column needs to be populated with the data and it can be populated by handling the QueryValue event.
C#
////Set Hashtable vaule for (int i = 0; i < this.gridGroupingControl1.Table.FilteredRecords.Count; i++) { UnboundValues.Add(this.gridGroupingControl1.Table.FilteredRecords[i].Id, i + 20); } this.gridGroupingControl1.TableDescriptor.QueryValue += new FieldValueEventHandler(TableDescriptor_QueryValue); void TableDescriptor_QueryValue(object sender, FieldValueEventArgs e) { int recordIndex = this.gridGroupingControl1.Table.PrimaryKeySortedRecords.IndexOf(e.Record); if (e.Field.Name == "UnBoundColumn" && e.Record.Id >= 0) { e.Value = UnboundValues[e.Record.Id]; } }
VB
'//Set Hashtable vaule For i As Integer = 0 To Me.gridGroupingControl1.Table.FilteredRecords.Count - 1 UnboundValues.Add(Me.gridGroupingControl1.Table.FilteredRecords(i).Id, i + 20) Next i AddHandler gridGroupingControl1.TableDescriptor.QueryValue, AddressOf TableDescriptor_QueryValue void TableDescriptor_QueryValue(Object sender, FieldValueEventArgs e) Dim recordIndex As Integer = Me.gridGroupingControl1.Table.PrimaryKeySortedRecords.IndexOf(e.Record) If e.Field.Name = " UnBoundColumn " AndAlso e.Record.Id >= 0 Then e.Value = UnboundValues(e.Record.Id) End If End Sub
Conclusion
I hope you enjoyed learning about how to group the unbound column in WinForms GridGroupingControl.
You can refer to our WinForms Grid Grouping Control’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms Grid Grouping Control documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms 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 Grid Control 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!