C# WinForms DragEnter 从不触发

标签 c# winforms windows-7 drag-and-drop

我对此感到困惑。我尝试在 DataGridView 上实现拖放操作。由于没有看到任何事件被触发,我尝试了一个带有文本框的简单表单。

我希望能够从 Windows 资源管理器中拖动文件或文件夹。

我遗漏了一些东西,因为这些事件永远不会触发。我确实读过 DragEvents, Windows 7 and UIPI但我仍然无法解决这个问题。

我没有想法,我欢迎你的建议。

public Form1()
{
    InitializeComponent();
    this.AllowDrop = true;
    textBox1.AllowDrop = true;
    textBox1.DragEnter += new DragEventHandler(textBox1_DragEnter);
    textBox1.DragDrop += new DragEventHandler(textBox1_DragDrop);
    textBox1.DragOver += new DragEventHandler(textBox1_DragOver);
}

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

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

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

这似乎应该 有效。我在 WP7 64 上进行了全新安装 - 包含所有更新,我没有运行病毒或恶意软件保护,或任何(据我所知)可以阻止这些事件触发的东西。

最佳答案

我遇到了同样的问题。这只是因为我正在从“以管理员身份运行” session 中进行调试。我认为,自从 VISTA 以来,就有一种安全措施可以防止掉落到特权应用程序。

关于C# WinForms DragEnter 从不触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8776719/

相关文章:

c# - 在 visual studio 中以编程方式打开文件

c++ - Windows 7 蓝牙堆栈和 API 是否支持耳机连接

c#-4.0 - log4net 不会在 Windows 7 上创建日志文件

c# - 如何在 C# 中将选中的复选框显示到消息框中

c# - 如何在不卸载整个产品的情况下将 Visual Studio 2013 Update 5 恢复到 Visual Studio 2013 Update 4

c# - 字典 : search key strings with a like feature

c# - 布局为 "zoom"的背景图像的实际尺寸

c# - .NET 字典中的元素是连续的吗?

c# - 在保持图像 C# 的纵横比的同时打印边距

wpf - 如何让 XBAP 在浏览器中运行而不是在 Windows 7 上下载?