Category / Section
How to the get the record details in WinForms GridGroupingControl?
1 min read
Getting the record details
If you want to get the record id, need to use Record class. To get all the records (say previous, current and next) while add or remove or edit, you need to use SourceListRecordChanged event. This event occurs when record in the underlying data source is added or removed or changed.
If you want to restrict the event only for adding new record you can validate using Syncfusion.Grouping.RecordChangedType.
C#
//Event Handler this.gridGroupingControl1.SourceListRecordChanged += gridGroupingControl1_SourceListRecordChanged; void gridGroupingControl1_SourceListRecordChanged(object sender, Syncfusion.Grouping.RecordChangedEventArgs e) { if (e.Action == Syncfusion.Grouping.RecordChangedType.Added) //Only for new record added { ExistingRecordId = e.Record.GetPreviousRecord().Id; //Existing record id. NewRecordID = e.Record.Id;//New record id MessageBox.Show("New record ID: " + NewRecordID + "\tExisting record ID: " + ExistingRecordId); } }
VB
'Event Handler Me.gridGroupingControl1.SourceListRecordChanged += gridGroupingControl1_SourceListRecordChanged Private Sub gridGroupingControl1_SourceListRecordChanged(ByVal sender As Object, ByVal e As Syncfusion.Grouping.RecordChangedEventArgs) If e.Action = Syncfusion.Grouping.RecordChangedType.Added Then 'Only for new record added ExistingRecordId = e.Record.GetPreviousRecord().Id 'Existing record id. NewRecordID = e.Record.Id 'New record id MessageBox.Show("New record ID: " & NewRecordID + Constants.vbTab & "Existing record ID: " & ExistingRecordId) End If End Sub
Screenshot:
Samples:
C#: RecordDetails_CS
VB: RecordDetails_VB