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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Basic GridGroupingControl Question

Thread ID:





61973 Jun 5,2007 03:05 PM UTC Jun 18,2007 10:33 PM UTC WinForms 3
Tags: GridControl
Dan Dorey
Asked On June 5, 2007 03:05 PM UTC

using v5.

I'm not sure why this is so hard to figure out, but I simply have an add button and when clicked on, I want to retrieve the row in the grid that is currently selected.


Saravanan A [Syncfusion]
Replied On June 5, 2007 09:34 PM UTC

Hi Dan,

You can get the selected ranges from the gridGroupingControl1.TableControl.Selections property. It return the GridRangeInfoList collection, which contains all the selected ranges.

Here is the code snippet to get the selected row index.

private void button1_Click(object sender, EventArgs e)
GridRangeInfoList rangeList;
if (this.gridGroupingControl1.TableControl.Selections.GetSelectedRanges(out rangeList, false))
foreach (GridRangeInfo range in rangeList)
if (range.RangeType == GridRangeInfoType.Rows)
for (int i = range.Top; i <= range.Bottom; i++)
Console.WriteLine("Row {0} is selected", i);

Best Regards,

Replied On June 18, 2007 08:42 PM UTC

I have a GridGroupingControl.
There are in total 4 rows in the control - using your code I've got the following output:

Row 3 is selected
Row 4 is selected
Row 5 is selected
Row 6 is selected

Where is this coming from? Why is the selection has an offset?

Thank you in advance

Saravanan A [Syncfusion]
Replied On June 18, 2007 10:33 PM UTC

Hi Dan,

Where is this coming from? Why is the selection has an offset?
The above code returns the RowIndex of the selected rows, with relative to the grid.
The grid will display each elements llike Caption, ColumnHeaders, FilterBar, AddNew row, ect., in different rows. Since these rows are displaying above the records, the rowindex of the records will get some offset and this offset will vary based on the number of elements displayed above the records.
You can find this offset using the gridGroupingControl1.TableControl.GetMinimumTopRowIndex() method. It returns the rowindex of the first record displayed in the grid.

If you are looking for the index of these selected rows in the binded datasource, please refer to the following KnowledgeBase article
How do I get the position of a row in the datasource from CurrentCell's rowIndex?

Best Regards,


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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