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

Drag drop operation from telerik grid to windows form treeview(nor telrik treeview,simple windows control)

1 Answer 153 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sithara
Top achievements
Rank 1
Sithara asked on 02 Feb 2020, 11:07 AM

Is it possible to drag a row from telerik grid to drop on windows form treeview control?

In my code i am able to drag the row from telerik grid but DragEnter event of windows form treeview control is not firing?

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 03 Feb 2020, 12:50 PM

Hello, Sithara,   

In order to implement drag and drop behavior between a RadControl, e.g. RadGridView and a standard MS Control, e.g. TreeView, it is suitable to use the Ole drag-and-drop functionality. Please refer to the following help article demonstrating how to use it: https://docs.microsoft.com/en-us/dotnet/framework/winforms/advanced/walkthrough-performing-a-drag-and-drop-operation-in-windows-forms 

I have prepared a very basic example to test whether the DragEnter event of the target TreeView will be fired and it seems to work as expected on my end:

        public RadForm1()
        {
            InitializeComponent();

            this.treeView1.AllowDrop = true;
            this.treeView1.DragEnter += treeView1_DragEnter;

            this.radGridView1.MouseDown += radGridView1_MouseDown;
            this.radGridView1.MouseMove += radGridView1_MouseMove;
        }

        private void radGridView1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left && downLocation != Point.Empty)
            {
                GridDataCellElement elementUnderMouse = this.radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridDataCellElement;
                if (elementUnderMouse!=null)
                {
                    this.radGridView1.DoDragDrop(elementUnderMouse.RowInfo, DragDropEffects.Move);
                }
            }
        }

        Point downLocation = Point.Empty;

        private void radGridView1_MouseDown(object sender, MouseEventArgs e)
        {
            downLocation = e.Location;
        }

        private void treeView1_DragEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Move;
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Sithara
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or