Drag and drop
Hello.
I would like to get drag drop like this.
Within grid - only move and all content
grid to grid - only copy the first Column's value but when this column's value is already in dropped grid, I don't want to drop this item.
now within grid is okay for move and content. But grid to grid has a problem.
my 2 girds have different column count and column's id.
grid1 and grid2 have only the same first column. I only want to drop first column value of selection from grid1 to grid2,not all it's content and all row value.
thanks in advance
Kay Zar
0
-
Hello,
It's quite easy. You have to add a handler for the Grid.DragDropContent event with a code that copies values between two grids:
grid2.DragDropContent += delegate(object sender, DragDropContentEventArgs e)
{
if ((e.TargetGrid != e.Source) && (e.Source is Grid) && e.TargetRow != null)
{
Grid source = (Grid) e.Source;
int i = 0;
e.TargetGrid.Selection.Clear();
e.TargetGrid.FocusedRow = null;
foreach (Row row in source.Selection)
{
int index = e.TargetRow.VisibleIndex + i;
if(index >= 0 && index < e.TargetGrid.Rows.Count)
{
Row targetRow = e.TargetGrid.Rows[index];
targetRow.Selected = true;
//Your logic here...
TestClass dataObject = targetRow.DataObject as TestClass;
if (dataObject != null)
{
dataObject.Value1 = (int)row["Value1"].Value;
}
}
i++;
}
e.TargetGrid.Invalidate();
e.Handled = true;
}
};Kind regards,
Dapfor0
Please sign in to leave a comment.
Comments
1 comment