【问题标题】:Can't drag and drop a file from a windows window to a winform in windows 10无法将文件从 windows 窗口拖放到 windows 10 中的 winform
【发布时间】:2019-09-25 09:04:08
【问题描述】:

我想将图片从 windows 拖放到 winforms 尽管我已经编写了所需的方法 DragDrop 和 DragEnter AllowDrag 是真的。 相同的应用功能在其他计算机上运行良好。

代码如下: 我不明白为什么 DragEnter 从未被解雇!

private void CtrlVignette_DragEnter(object sender, DragEventArgs e) `
{
    if ((((sender != CtrlVignette) &&
       (e.Data.GetDataPresent(DataFormats.FileDrop, false) == true)) ||
        ((sender == CtrlVignette) &&
         (e.Data.GetDataPresent("objet", false) == false))) &&
       (Selectedpatient != null))
            e.Effect = DragDropEffects.All;
}

private void CtrlVignette_DragDrop(object sender, DragEventArgs e)
{
    // the code of this method is too long and it works very well
 }

CtrlVignette.AllowDrop 为真

【问题讨论】:

  • 请贴出代码,我们无法读心。如果您想让我们告诉您您的代码有什么问题,那么我们必须看到它:)
  • 我想从 Windows 拖放图片 含义:从文件资源管理器/桌面等或其他应用程序?源应用程序必须允许拖动! Example 用于文件资源管理器。
  • 谢谢你 :) @Mong Zhu
  • 标准的 it-doesn't-work 场景是试图拖动到运行提升的进程的窗口。通常在运行 VS 提升时发生。 UAC的另一个方面called UIPI.
  • 我想从桌面到我的应用程序@Taw

标签: c# .net windows winforms drag-and-drop


【解决方案1】:

解决方案:禁用 LUA

第 1 步:打开 RegisterEditor。

第2步:进入以下目录:(Ordinateur\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System)

第三步:将EnableLUA值从1修改为0

第四步:重启电脑

最后,我感谢大家@Hans Passant @Taw、@Mohamad Shahrestani 和 @Mong Zhu

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-09
    • 1970-01-01
    • 2011-03-11
    • 1970-01-01
    • 2012-05-02
    相关资源
    最近更新 更多