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

Get selected rows

Hi,

we have Syncfusion 6.3.1.8. I know, not the latest but I wonder if it is my way of thinking or a bug in that version:
The user can select rows in a griddataboundgrid. If more than one row is selected, a special button has to be disabled. The problem: The user selects via mouse: code runs ok, button is disabled. User selects via keyboard: code allways returns that only one row is selected!

Dim gridList As Syncfusion.Windows.Forms.Grid.GridRangeInfoList = New Syncfusion.Windows.Forms.Grid.GridRangeInfoList()

m_ReviewTaskUserGridDataBoundGrid.Selections().GetSelectedRanges(gridList, True)

I can see the selected part in the item "gridList". Always shows only the newly selected row.
-> is there a fast way to find out if there is more than one row selected?

regards
sascha



3 Replies

JJ Jisha Joy Syncfusion Team July 14, 2009 09:54 AM UTC

Hi Sascha,

Thank you for posting query to us.

For getting the seleted rows count, you will have to iterate through the selections and add up the rows. See the code:

private void button1_Click(object sender, EventArgs e)
{

int selectedRows = 0;

foreach (GridRangeInfo range in this.gridDataBoundGrid1.Selections.GetSelectedRows(true, false))
{

selectedRows += range.Bottom - range.Top + 1;

}

Console.WriteLine(selectedRows.ToString());


}

Let me know if this helps.

Regards,
Jisha


MS Mr. Sascha Wald July 14, 2009 11:12 AM UTC

Sorry, doesn't work here.
When I select a row and expand the selection with the keyboard, it returns always "1" (the newly added selection and not the whole selection-range).

regards sascha


JJ Jisha Joy Syncfusion Team July 15, 2009 10:09 AM UTC

Hi Sascha,

Thank you for your update.

Instead of using the GetSelectedRows, try using GetSelectedRanges method and let me know if this helps.

See the code:
private void button1_Click(object sender, EventArgs e)
{
int selectedRows = 0;

GridRangeInfoList list= new GridRangeInfoList();
this.gridDataBoundGrid1.Selections.GetSelectedRanges(out list, true);
foreach (GridRangeInfo range in list) {

selectedRows += range.Bottom - range.Top + 1;

}

Console.WriteLine(selectedRows.ToString());


}

Regards,
Jisha

Loader.
Live Chat Icon For mobile
Up arrow icon