How to retrieve and modify record in WinForms GridGroupingControl?
Change the selected records in grid
In order to get the selected records from the WinForms GridGroupingControl, the SelectedRecords property can be used. The SelectedRecords property holds all the selected records in the GridGroupingControl.
Retrieving the selected records
The
particular record can be retrieved by using the Record property
of the SelectedRecords.
C#
private void getSelectedRowBtn_Click(object sender, EventArgs e)
{
foreach (SelectedRecord selectedRecord in this.gridGroupingControl1.Table.SelectedRecords)
{
MessageBox.Show(selectedRecord.Record.Info);
}
}
VB
Private Sub getSelectedRowBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles getSelectedRowBtn.Click
For Each selectedRecord As SelectedRecord In Me.gridGroupingControl1.Table.SelectedRecords
MessageBox.Show(selectedRecord.Record.Info)
Next selectedRecord
End Sub
Modifying the selected records
The record can be modified by using the SetValue method of a particular record based on the columns.
C#
private void modifySelectedRowBtn_Click(object sender, EventArgs e)
{
foreach (SelectedRecord selectedRecord in this.gridGroupingControl1.Table.SelectedRecords)
{
foreach (GridColumnDescriptor column in this.gridGroupingControl1.TableDescriptor.Columns)
{
selectedRecord.Record.SetValue(column.Name, "Modified_Record");
}
}
}
VB
Private Sub modifySelectedRowBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles modifySelectedRowBtn.Click
For Each selectedRecord As SelectedRecord In Me.gridGroupingControl1.Table.SelectedRecords
For Each column As GridColumnDescriptor In Me.gridGroupingControl1.TableDescriptor.Columns
selectedRecord.Record.SetValue(column.Name, "Modified_Record")
Next column
Next selectedRecord
End Sub
The screenshot below illustrates retrieving and modifying the records
Figure 1: Retrieving the selected records
Figure 2: Modifying the selected record in grid.
Conclusion
I hope you
enjoyed learning about how to retrieve and modify record 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!