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.
Unfortunately, activation email could not send to your email. Please try again.

Getting selected rows in right order

Thread ID:

Created:

Updated:

Platform:

Replies:

100176 Jul 11,2011 07:01 AM Jul 19,2011 10:02 AM Windows Forms 3
loading
Tags: GridControl
Christian Rattat
Asked On July 11, 2011 07:01 AM

Hi,

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 8.204.0.18.

Regards,
Christian


Jisha Joy [Syncfusion]
Replied On July 14, 2011 08:22 AM

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 + " ");

}
Console.WriteLine();

}
}
}
}



Sample for your reference:

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GCSelections-1468458982.zip

Please let me know if you have any questions.

Regards,
Jisha




Christian Rattat
Replied On July 14, 2011 02:39 PM

Hi,

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,
Christian


Kalaiarasan B [Syncfusion]
Replied On July 19, 2011 10:02 AM

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.

Regards,
Kalai.


CONFIRMATION

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.

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.

;