如何拖放图像 [英] how to drag and drop image
本文介绍了如何拖放图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将图像拖放到表单中
i want to drag and drop image into a form
推荐答案
Google是您的朋友:
http://msdn.microsoft.com/en-us/library/aa289508 (v = vs.71).aspx [
Google is your friend:
http://msdn.microsoft.com/en-us/library/aa289508(v=vs.71).aspx[^]
要准确回答这个问题很困难,但是拖放并不困难.
假设您要将图像从资源管理器拖到窗体上:
1)将Form AllowDrop属性设置为true.
2)处理Form DragEnter事件.
It''s difficult to answer this accurately, but Drag and Drop is not difficult.
Assuming you want to drag an image from Explorer onto you form:
1) Set the Form AllowDrop property to true.
2) Handle the Form DragEnter event.
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
3)处理Form DragDrop事件.
3) Handle the Form DragDrop event.
Dim files As String() = DirectCast(e.Data.GetData(DataFormats.FileDrop, False), String())
For Each file As String In files
Console.WriteLine(file)
Next
然后您可以检查图像并根据需要使用该文件.
You can then check for images and use the file as you wish.
这篇关于如何拖放图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文