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
close icon

Move items between 2 GridDataBoundGrid

In my application, we implemented two GridDataBoundGrid that are tied to a datasource. We need to be able to move items between the 2 grids. I have looked at various methods, but is unable to figure out how to: a. Get the current selected rows? (might not be contiguous) I tried datagrid.Selections.GetSelectedRows(true, false); datagrid.Selections.GetSelectedRows(true, false).ActiveRange; b. How to map the "selected row to the row in the datasource"? I am trying to use datagrid.DataSource.Remove() or datagrid.DataSource.RemoveAt() Can any one provide me with an example? This sounds like a very easy thing to do, but I am new to the Syncfusion framework. Thanks you for your help!

1 Reply

AD Administrator Syncfusion Team August 20, 2003 10:02 PM UTC

Here is code that loops through all the selected rows.
private void button1_Click(object sender, EventArgs e)
{			
	int totalRows = 0;
	string printRows = "rows: ";
	foreach(GridRangeInfo range in this.gridControl1.Selections.GetSelectedRows(true,false))
	{
		totalRows += range.Bottom - range.Top + 1;			
		for(int i = range.Top; i <= range.Bottom; i++)
		{
			printRows += i.ToString()+"  ";
		}
	}
	MessageBox.Show(string.Format("Total Rows: {0}  Rows: {1}", totalRows, printRows));
}
To delete a record at a rowindex in the grid, you can use: gridDataBoundGrid1.DeleteRecordsAtRowIndex Or, you can also use gridDataBoundGrid1.Binder.RemoveRecords. But to use this, you need to use gridDataBoundGrid1.Binder.RowIndexToPosition to convert the rowindex to a record position.

Loader.
Live Chat Icon For mobile
Up arrow icon