在窗体上的图片框上实现拖放
Implementing Drop on Picturebox on Form
我似乎无法将文件从桌面拖放到窗体上的 PictureBox 中。
我浏览了我能找到的所有文档,但无论如何光标始终停留在停止标志上。
我所做的是:
将表单的 "AllowDrop" 设置为 True。
在我的代码中有
Private Sub pb0A_DragOver(sender As Object, e As DragEventArgs) Handles pb0A.DragOver
e.Effect = DragDropEffects.Copy
End Sub
Private Sub pb0A_DragEnter(sender As Object, e As DragEventArgs) Handles pb0A.DragEnter
e.Effect = DragDropEffects.Copy
End Sub
在我读到的文档中,我应该将 PictureBox 的 属性 "AllowDrop" 设置为 True,但是使用 Framework 4.5.2,我没有这个 属性。
我不是 运行 VS 管理员。
这里还有什么问题?
出于某种原因,Microsoft 有意隐藏了 PictureBox.AllowDrop
property。它在设计器中不可见,也不被 IntelliSense 列出,但它确实存在,因此您仍然可以通过代码设置它:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox1.AllowDrop = True
End Sub
我似乎无法将文件从桌面拖放到窗体上的 PictureBox 中。
我浏览了我能找到的所有文档,但无论如何光标始终停留在停止标志上。
我所做的是:
将表单的 "AllowDrop" 设置为 True。
在我的代码中有
Private Sub pb0A_DragOver(sender As Object, e As DragEventArgs) Handles pb0A.DragOver
e.Effect = DragDropEffects.Copy
End Sub
Private Sub pb0A_DragEnter(sender As Object, e As DragEventArgs) Handles pb0A.DragEnter
e.Effect = DragDropEffects.Copy
End Sub
在我读到的文档中,我应该将 PictureBox 的 属性 "AllowDrop" 设置为 True,但是使用 Framework 4.5.2,我没有这个 属性。
我不是 运行 VS 管理员。
这里还有什么问题?
出于某种原因,Microsoft 有意隐藏了 PictureBox.AllowDrop
property。它在设计器中不可见,也不被 IntelliSense 列出,但它确实存在,因此您仍然可以通过代码设置它:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox1.AllowDrop = True
End Sub