拖放问题 [英] Problems with drag drop

查看:82
本文介绍了拖放问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将文件从资源管理器拖到我的控件(面板)中

初始化代码:

I am trying to drag files from Explorer to my control (a panel)

Initialising code:

Friend Const CtrlMask As Byte = 8


'
'ListView
'
Me.AllowDrop = True
Me.Controls.Add(Me.MainPanel)
Me.Controls.Add(Me.ToolPanel)
Me.Name = "ListView"
Me.ViewMenu.ResumeLayout(False)
Me.ResumeLayout(False)


在代码中:


In the code:

Private Sub ListView_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
   Dim f As String() = CType(e.Data.GetData(DataFormats.FileDrop), String())
   Select Case e.Effect
      Case DragDropEffects.Copy : RaiseEvent FilesDropped(f, True)
      Case DragDropEffects.Move : RaiseEvent FilesDropped(f, False)
   End Select
End Sub

Private Sub ListView_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
   If (e.KeyState And CtrlMask) = CtrlMask Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.Move
End Sub


我在DragEnter上设置了一个断点,但它从未到达那里.

我看不到我在做什么错.


I put a breakpoint on DragEnter but it never gets there.

I cannot see what I am doing wrong. Can anyone else?

推荐答案

您不能设置表单/面板的AllowDrop并期望它的子控件成为放置目标.将您的ListView控件的AllowDrop设置为true.
You cannot set your form/panel''s AllowDrop and expect it''s child controls to become drop targets. Set your ListView control''s AllowDrop to true instead.


这篇关于拖放问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆