We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to access the cell values for all the selected rows in WinForms GridControl?

Platform: WinForms |
Control: GridControl

Accessing the cell values for selected rows

To access the cell values of the selected records, get the GridRangeInfoList of the selected rows. By using the list, loop through the range to get the fields.


private void btnGetCellValue_Click(object sender, EventArgs e)
    GridRangeInfoList list = this.gridControl1.Selections.GetSelectedRows(true, false);
    foreach (GridRangeInfo range in list)
        for (int i = range.Top; i <= range.Bottom; i++)
            for (int j = 1; j <= this.gridControl1.Model.ColCount; j++)
                //Prints the text in the output screen.
                Trace.WriteLine(this.gridControl1[i, j].Text);


Private Sub btnGetCellValue_Click (ByVal sender As Object, ByVal e As EventArgs)
    Dim list As GridRangeInfoList = Me.gridControl1.Selections.GetSelectedRows(True, False)
    For Each range As GridRangeInfo In list
       For i As Integer = range.Top To range.Bottom
          For j As Integer = 1 To Me.gridControl1.Model.ColCount
             'Prints the text in the output screen.
             Trace.WriteLine(Me.gridControl1(i, j).Text)
          Next j
       Next i
    Next range
End Sub


GridControl with selected records

Figure 1: GridControl with selected records

Display the selected rows data in output window

Figure 2: Output screen


C#: GetSelectedRowValues




2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile