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

How to get the selected row details in simple way?

Thread ID:

Created:

Updated:

Platform:

Replies:

58891 Mar 30,2007 09:12 AM UTC Apr 3,2007 02:52 AM UTC WinForms 3
loading
Tags: GridControl
Nhilesh Baua
Asked On March 30, 2007 09:12 AM UTC

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.

haneefm [Syncfusion]
Replied On 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

Nhilesh Baua
Replied On 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.

haneefm [Syncfusion]
Replied On 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

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.

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

;