Cancel a Drag and Drop Operation

3 posts, 1 answers
  1. Leonardo
    Leonardo avatar
    2 posts
    Member since:
    Aug 2015

    Posted 18 May 2017 Link to this post

    Is it possible to cancel a Drag and Drop Operation like on TreeView?
    http://docs.telerik.com/devtools/winforms/treeview/drag-and-drop/cancel-a-drag-and-drop-operation

    I'd like to impose some restrictions on drop operation based on from/destination rows.

    Thank you.

    Leonardo

  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    2838 posts

    Posted 19 May 2017 Link to this post

    Hi Leonardo,

    Thank you for writing.

    You can use the PreviewDragDrop event. Here is an example:
    public RadForm1()
    {
        InitializeComponent();
        for (int i = 0; i < 10; i++)
        {
            string[] values = new string[] { "Row" + i, i + "", "Test", "Test", "Test" };
            radGridView1.Rows.Add(values);
        }
        var service = radGridView1.GridViewElement.GetDragDropService();
     
        service.PreviewDragDrop += Service_PreviewDragDrop;
     
        radGridView1.AllowRowReorder = true;
    }
     
    private void Service_PreviewDragDrop(object sender, Telerik.WinControls.RadDropEventArgs e)
    {
        var row = e.HitTarget as GridDataRowElement;
        if (row != null && int.Parse(row.RowInfo.Cells[1].Value.ToString()) > 5)
        {
            e.Handled = true;
            RadMessageBox.Show("Connot Drop Here");
        }
    }

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Leonardo
    Leonardo avatar
    2 posts
    Member since:
    Aug 2015

    Posted 19 May 2017 in reply to Dimitar Link to this post

    Thank you very much Dimitar.

    It works great!

    Regards
    Leonardo

Back to Top