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

DragDrop event not fired but Over/Enter/Leave yes in RadForm

5 Answers 784 Views
Form
This is a migrated thread and some comments may be shown as answers.
FMorales
Top achievements
Rank 1
FMorales asked on 22 Feb 2017, 11:58 AM

Hi, 

I am just trying to drag&drop a file from the desktop to a simple radForm but DragDrop event do not fired, others events as DragEnter/DragOver/DragLeave works without problems but I can not detect when the user perform drag&Drop with the file into the form.

any idea why I can not catch this event?

namespace Drag
{
    partial class RadForm1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
 
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
 
        #region Windows Form Designer generated code
 
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.visualStudio2012LightTheme1 = new Telerik.WinControls.Themes.VisualStudio2012LightTheme();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
            this.SuspendLayout();
            //
            // RadForm1
            //
            this.AllowDrop = true;
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(643, 488);
            this.Margin = new System.Windows.Forms.Padding(4);
            this.Name = "RadForm1";
            //
            //
            //
            this.RootElement.ApplyShapeToControl = true;
            this.Text = "RadForm1";
            this.ThemeName = "VisualStudio2012Light";
            this.DragDrop += new System.Windows.Forms.DragEventHandler(this.RadForm1_DragDrop);
            this.DragEnter += new System.Windows.Forms.DragEventHandler(this.RadForm1_DragEnter);
            this.DragOver += new System.Windows.Forms.DragEventHandler(this.RadForm1_DragOver);
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
            this.ResumeLayout(false);
 
        }
 
        #endregion
 
        private Telerik.WinControls.Themes.VisualStudio2012LightTheme visualStudio2012LightTheme1;
    }
}
 
namespace Drag
{
    partial class RadForm1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
 
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
 
        #region Windows Form Designer generated code
 
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.visualStudio2012LightTheme1 = new Telerik.WinControls.Themes.VisualStudio2012LightTheme();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
            this.SuspendLayout();
            //
            // RadForm1
            //
            this.AllowDrop = true;
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(643, 488);
            this.Margin = new System.Windows.Forms.Padding(4);
            this.Name = "RadForm1";
            //
            //
            //
            this.RootElement.ApplyShapeToControl = true;
            this.Text = "RadForm1";
            this.ThemeName = "VisualStudio2012Light";
            this.DragDrop += new System.Windows.Forms.DragEventHandler(this.RadForm1_DragDrop);
            this.DragEnter += new System.Windows.Forms.DragEventHandler(this.RadForm1_DragEnter);
            this.DragOver += new System.Windows.Forms.DragEventHandler(this.RadForm1_DragOver);
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
            this.ResumeLayout(false);
 
        }
 
        #endregion
 
        private Telerik.WinControls.Themes.VisualStudio2012LightTheme visualStudio2012LightTheme1;
    }
}

 

Thanks a lot.

Francisco

5 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Feb 2017, 01:29 PM
Hello Francisco,

Thank you for writing.  

Following the provided information I have prepared a sample project for your reference. The DragEnter and DragDrop events are fired on my end as expected. Please refer to the attached gif file illustrating the behavior on my end. If you are still experiencing any further difficulties, feel free to modify it in a way to reproduce the experienced issue and get back to me with it so I can investigate the precise case. Thank you in advance. Additional information about the standard drag and drop functionality in WinForms is available here: https://msdn.microsoft.com/en-us/library/aa984430(v=vs.71).aspx

I am looking forward to your reply.

Regards,
Dess
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
Sam
Top achievements
Rank 1
answered on 09 Jul 2020, 09:08 PM

Could you also provide a VB.NET example. I tried your example in vb, however cannot make it work. 

 

Imports Telerik.WinControls.UI
Imports System.Drawing.Drawing2D
Imports Telerik.WinControls
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
 
Public Class FrmTelerikTest
 
 
    Public Sub New()
        InitializeComponent()
        Me.AllowDrop = True
        AddHandler Me.DragEnter, AddressOf RadForm1_DragEnter
        AddHandler Me.DragDrop, AddressOf RadForm1_DragDrop
    End Sub
 
    Private Sub RadForm1_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs)
        Me.Text = "Drag drop"
    End Sub
 
    Private Sub RadForm1_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs)
        e.Effect = DragDropEffects.All
        Me.Text = "Drag enter"
    End Sub
End Class
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Jul 2020, 09:01 AM

Hello, Sam,

Your code looks correct. I have prepared a sample VB.NET project with your code snippet for your reference. Please refer to the attached zip file. The attached gif file illustrates the achieved result on my end.

Am I missing something? Could you please specify the exact steps how to reproduce the problem that you are facing?

I am looking forward to your reply.

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

0
Sam
Top achievements
Rank 1
answered on 13 Jul 2020, 09:02 PM

I spent a little time to figure out the real reason of my problem. 

"Dropping a file onto a form (or a form's component) doesn't work if VS is started in Administrator mode."

This issue affects the regular WinForm and RadForm. Because I have to use VS in admin, so I can only make it work after I directly open the exe file after I build it in the VS. 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Jul 2020, 08:54 AM

Hi, Sam,

Indeed, after running Visual Studio as administrator, the OLE drag and drop behavior doesn't work any more.  

After further research in general programming forums, I have found the following useful threads on this topic:

https://stackoverflow.com/questions/17416765/drag-and-drop-event-can-not-be-fired-when-running-visual-studio-in-administrator 

https://stackoverflow.com/questions/26628492/drag-and-drop-not-working-in-c-sharp-winforms-application 

https://social.msdn.microsoft.com/Forums/vstudio/en-US/940d10c6-466d-4962-9a3b-48e583a60108/dragdrop-event-not-launched?forum=csharpgeneral 

https://stackoverflow.com/questions/21651580/drag-and-drop-not-working-in-c-sharp 

I believe that you will find them useful regarding this functionality.

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

Tags
Form
Asked by
FMorales
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Sam
Top achievements
Rank 1
Share this question
or