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

How to get the selected row details in simple way?

Hi,

I am using GridControl 4.402.0.55.
I have approx 25 rows in first place and I am allowing user to select some rows(subject to some conditions), However I am not able to get the selected rows data in a seperate collection.

What is the simplest way I can get the selected rows details without iteration in whole data and can store in Custom Entity Collection?

PLEASE POST YOUR CODE AND NOT THE ZIP FILES.

Thanks in advance.

3 Replies

HA haneefm Syncfusion Team March 30, 2007 02:21 PM UTC

Hi Nhilesh,

Use GetSelectedRows method from the GridModelSelections to get the selected rows in the grid. It returns the GridRangeInfoList with row ranges. It takes two parameters.

bRangeRowsOnly -True if only selected rows should be returned; False if you want to treat single range cell selections as full row selections.
considerCurrentCell - True if current cell should be returned as selected range if there are no other selected ranges.

[c#]

foreach (GridRangeInfo r in this.gridDataBoundGrid1.Model.Selections.GetSelectedRows(true, true))
{
Console.WrtieLine( "RangeInfo:" + r.Info);
}

Best regards,
Haneef


NB Nhilesh Baua April 2, 2007 05:49 AM UTC

Hi Haneef,

I did almost same thing b4,
This is my code shown as under:

/**********************************************/
GridRangeInfoList grInfoList;
this.grdPareto.Selections.GetSelectedRanges(out grInfoList, true);

//Loop through Range Information and prompt
foreach (GridRangeInfo grRangeInfo in grInfoList)
{
if (grRangeInfo.IsRows)
{
MessageBox.Show(grRangeInfo.Info.ToString());
}
}
/***********************************************/

However I always get MessageBox showing only "Rn" where n is the number of that row and this is the value of the row headers.

I want the complete row data for all the cells along with the row identifer.

Can you please show me how to do it?
Thanks in advance and thanks for PASTEing the code.

Regards,
Nhilesh Baua.


HA haneefm Syncfusion Team April 3, 2007 02:52 AM UTC

Hi Nhilesh,

Use the Table.DisplayElements property of the grid to find the corresponding record in a grid. Here is a code snippet that shows you "How to access a record from the rowindex in a grid?"

GridRangeInfoList grInfoList;
this.grdPareto.Selections.GetSelectedRanges(out grInfoList, true);

foreach (GridRangeInfo grRangeInfo in grInfoList)
{
if (grRangeInfo.IsRows)
{
string strRowInfo = string.Empty;
for(int i = grRangeInfo.Top;i<=grRangeInfo.Bottom;i++)
{
// using the displayelements property of the grid, we can find the corresponding record.
Record r = gridGroupingControl1.Table.DisplayElements[i].ParentRecord;
if( r != null)
{
strRowInfo += string.Format("{0}===>{1}",i r.Info) + Environment.NewLine;
}
}
MessageBox.Show(strRowInfo);
}
}

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon