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

Getting selected rows in right order

Thread ID:





100176 Jul 11,2011 11:01 AM UTC Jul 19,2011 02:02 PM UTC WinForms 3
Tags: GridControl
Christian Rattat
Asked On July 11, 2011 11:01 AM UTC


I need to get all selected rows from a grid control in the right order. If I do a foreach loop through grid.Selections I get the ranges in wrong order. How do I get the selected rows in numerical order (e.g. 1,2,7,8,9 instead of 7,8,9,1,2 as I get it now) without sorting selected row indexes myself?

I'm using version


Jisha Joy [Syncfusion]
Replied On July 14, 2011 12:22 PM UTC

Hi Christian,

Thank you for using Syncfusion products.

You could get the currently selected rows by getting the selected ranges by using GetSelectedRows method and iterate through GridRangeInfoList.

See the code:

private void button1_Click(object sender, EventArgs e)
GridRangeInfoList rangeList = this.gridControl1.Selections.GetSelectedRows(true, false);
if (rangeList.Count > 0)
foreach (GridRangeInfo range in rangeList)

for (int row = range.Top; row <= range.Bottom; row++)
for (int col = 1; col <= gridControl1.ColCount; col++)
Console.Write( this.gridControl1[row, col].CellValue + " ");



Sample for your reference:


Please let me know if you have any questions.


Christian Rattat
Replied On July 14, 2011 06:39 PM UTC


that's what I already tried but as mentioned in my original post, I get the selected rows not ordered but in arbitrary order. With your sample I need to put the row numbers first all in a temporary list, sort them and then I can iterate through the selected rows top down in the right order.

So what I need is a method that gives me the selected rows ordered by row number without having to sort them manually each time. Is there any method like this? It's quite annoying to first iterate through a couple thousand indexes, sort them each time just to iterate it again then in the right order.

Thanks and regards,

Kalaiarasan B [Syncfusion]
Replied On July 19, 2011 02:02 PM UTC

Hi Christian,

Thank you for the update.

We are checking for other possibilities other than using a temporary list to sort the rows by row number,but also by optimizing the iteration to sort in the temp list, you can achieve it. We will update you with the solution shortly.

Appreciate your patience.



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