This is a migrated thread and some comments may be shown as answers.

Cancel a Drag and Drop Operation

2 Answers 258 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Leonardo
Top achievements
Rank 1
Leonardo asked on 18 May 2017, 12:51 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 19 May 2017, 10:37 AM
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.
0
Leonardo
Top achievements
Rank 1
answered on 19 May 2017, 02:51 PM

Thank you very much Dimitar.

It works great!

Regards
Leonardo

Tags
GridView
Asked by
Leonardo
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Leonardo
Top achievements
Rank 1
Share this question
or