当将项目从 Outlook 电子邮件拖到 Winforms 应用程序时(控件是GalleryControl
DevExpress 的一个,DragDrop 事件没有触发,即使我在 DragEnter 事件处理程序中手动设置了“DragDropEffects.Move”。(已确认这是触发)
然而,DragDrop 事件只会在从 Windows 资源管理器中拖动普通文件时触发。
private async void gcImages_DragDrop(object sender, DragEventArgs e)
{
string[] fileNames = null;
if (e.Data.GetDataPresent(DataFormats.FileDrop, false) == true)
{
fileNames = (string[])e.Data.GetData(DataFormats.FileDrop);
}
else if (e.Data.GetDataPresent("FileGroupDescriptor"))
{
OutlookDataObject dataObject = new OutlookDataObject(e.Data);
string[] filenames = (string[])dataObject.GetData("FileGroupDescriptor");
}
// do stuff async with file names
}
private void gcImages_DragEnter(object sender, DragEventArgs e)
{
// This event fires, no matter what i drag onto it. (Files from explorer, attachments from Outlook etc)
// However even after setting the effect as per below, the cursor still shows the 'not allowed' symbol.
e.Effect = DragDropEffects.Move;
}
我已经启用AllowDrop = true
了控件,它可以完美地与 Windows 资源管理器文件一起使用,而不是 Outlook 文件。
奇怪的是 DragEnter 事件正在触发,但 DragDrop 事件不会与 Outlook 附件一起触发。