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.

Get Selected Rows GDBG

Thread ID:

Created:

Updated:

Platform:

Replies:

68770 Oct 1,2007 10:27 AM Oct 1,2007 12:04 PM Windows Forms 2
loading
Tags: GridControl
John Slater
Asked On October 1, 2007 10:27 AM

After performing a control-click to select multiple rows, how can I retrieve the corresponding DataRow's for a GridDataboundGrid? Version 5.2

thx

Administrator [Syncfusion]
Replied On October 1, 2007 11:38 AM

Here is code in a button click handler that I think does what you requested.


private void button1_Click(object sender, EventArgs e)
{
GridRangeInfoList rangeList = gridDataBoundGrid1.Selections.GetSelectedRows(true, false);

CurrencyManager cm = gridDataBoundGrid1.BindingContext[gridDataBoundGrid1.DataSource, gridDataBoundGrid1.DataMember] as CurrencyManager;

if (cm != null)
{
DataView dv = cm.List as DataView;
if (dv != null)
{
foreach (GridRangeInfo range in rangeList)
{
for (int row = range.Top; row <= range.Bottom; ++row)
{
DataRow dr = dv[gridDataBoundGrid1.Binder.RowIndexToPosition(row)].Row;
Console.WriteLine(dr[0]);
}
}
}
}
}


John Slater
Replied On October 1, 2007 12:04 PM

Thanks Clay,

As always, it works perfectly.

>Here is code in a button click handler that I think does what you requested.


private void button1_Click(object sender, EventArgs e)
{
GridRangeInfoList rangeList = gridDataBoundGrid1.Selections.GetSelectedRows(true, false);

CurrencyManager cm = gridDataBoundGrid1.BindingContext[gridDataBoundGrid1.DataSource, gridDataBoundGrid1.DataMember] as CurrencyManager;

if (cm != null)
{
DataView dv = cm.List as DataView;
if (dv != null)
{
foreach (GridRangeInfo range in rangeList)
{
for (int row = range.Top; row <= range.Bottom; ++row)
{
DataRow dr = dv[gridDataBoundGrid1.Binder.RowIndexToPosition(row)].Row;
Console.WriteLine(dr[0]);
}
}
}
}
}



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.

;