Posted 19 years ago
by Jason Whitted
-
Owner,
Etalisoft, LLC
I'm trying to load a file when it is dropped onto the editor; however, I'm running into a problem where the PasteDragDrop event is firing on DragEnter instead of DragDrop.
Below is a small application which illistrates the problem.
Below is a small application which illistrates the problem.
using System;
using System.Windows.Forms;
using ActiproSoftware.SyntaxEditor;
using System.Diagnostics;
public partial class Form1 : Form
{
private SyntaxEditor editor;
public Form1()
{
editor = new SyntaxEditor();
editor.Dock = DockStyle.Fill;
this.Controls.Add(editor);
editor.AllowDrop = true;
editor.PasteDragDrop += new PasteDragDropEventHandler(editor_PasteDragDrop);
}
private void editor_PasteDragDrop(object sender, PasteDragDropEventArgs e)
{
if (e.DataObject.GetDataPresent(DataFormats.FileDrop))
{
string[] files = e.DataObject.GetData(DataFormats.FileDrop) as string[];
if (files == null || files.Length == 0) return;
Debug.WriteLine(String.Format("{0:hh:mm:ss.fff} editor_PasteDragDrop --> LoadFile", DateTime.Now));
editor.Document.LoadFile(files[0]);
}
}
}