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 GroupingControl 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 how to group the unbound column in WinForms GridGroupingControl.
You can refer to WinForms GridGroupingControl feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms Grid Grouping example 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!