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.

Basic GridGroupingControl Question

Thread ID:

Created:

Updated:

Platform:

Replies:

61973 Jun 5,2007 11:05 AM Jun 18,2007 06:33 PM Windows Forms 3
loading
Tags: GridControl
Dan Dorey
Asked On June 5, 2007 11:05 AM

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.

Thanks,
Dan

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

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

Deian
Replied On June 18, 2007 04:42 PM

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
Deian

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

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,
Saravanan.

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.

;