Hi,
Set the picturebox1.allowdrop=true. This should allow to
drag an image from a webpage to the picturebox.
Private Sub PictureBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop, False) Then
Dim strFile() As String = CType(e.Data.GetData(DataFormats.FileDrop),
String())
Dim fi As New System.IO.FileInfo(strFile(0))
If fi.Extension = ".gif" Or fi.Extension = ".bmp" Or _
fi.Extension = ".jpg" Or fi.Extension = ".jpeg" Then
e.Effect = DragDropEffects.Copy
End If
End If
End Sub
Private Sub PictureBox1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragDrop
Dim s() As String = CType(e.Data.GetData(DataFormats.FileDrop), String())
Dim fs As New System.IO.FileStream(s(0), IO.FileMode.Open)
Dim bm As New Bitmap(fs)
fs.Close()
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox1.Image = bm
End Sub
Ken
--------------------------
I am creating an application to categorize images from websites. I
have tried a few sets of sample code to try to copy the image when it
is dropped into my vb.net application but it seem that the dragdrop
event never fires. I have enabled the AllowDrop. Does anyone have
any sample code or suggestion?
Thanks,
William