Skip to main content

Drag and drop

Comments

1 comment

  • Dapfor Team

    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,
    Dapfor

    0

Please sign in to leave a comment.

Powered by Zendesk