gpt4 book ai didi

.net - ListView 的 DragEnter、DragOver、DragDrop 事件未引发 (AllowDrop=True)

转载 作者:行者123 更新时间:2023-12-04 01:50:35 35 4
gpt4 key购买 nike

这个很奇怪:

我的应用程序运行良好,但突然间该死的 ListView 控件的事件不再引发。它只是来来去去,没有任何明确的原因。 (显然)我已将 AllowDrop 属性设置为 True 并按如下方式处理 DragEnter、DragOver 和 DragDrop 事件:

Private Sub lstApplications_DragDrop(ByVal sender As Object, ByVal e As    System.Windows.Forms.DragEventArgs) Handles lstApplications.DragDrop, Me.DragDrop
m_fileNames = CType(e.Data.GetData(DataFormats.FileDrop), String())
mnuType.Show(Cursor.Position, ToolStripDropDownDirection.BelowLeft)
End Sub

Private Sub lstApplications_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lstApplications.DragEnter, Me.DragEnter, lstApplications.DragOver, Me.DragOver
If chkMode.Checked OrElse Not e.Data.GetDataPresent(DataFormats.FileDrop, True) Then
e.Effect = DragDropEffects.None
Else
e.Effect = DragDropEffects.Copy
End If
End Sub

我在这两种方法中编写了什么代码并不重要,因为没有引发任何事件。
有什么我在这里想念的吗?

我在另一台机器上运行相同的应用程序,它运行得很好。然后我重新启动了我自己的机器,一切又开始工作了。我不确定,但似乎 Windows 有问题。

最佳答案

我只是因为类似的问题而遭受了数小时的痛苦。拖放工作的三个强制性要求:

  • 确保您的目标 UI 元素具有 AllowDrop="True" ,整个应用程序不需要这个,只需要你想要启用的元素。
  • 如果未设置背景,某些元素不会接收某些鼠标事件(包括 d&d)。 Background="Transparent"会做。
  • 以管理员权限运行任何程序都会导致拖放操作。确保你启动了visual studio 没有管理员权限 .
  • 关于.net - ListView 的 DragEnter、DragOver、DragDrop 事件未引发 (AllowDrop=True),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/557208/

    35 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com