By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

Drag images from IE to vb.net application

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

--------------------------

"William" <bk******@hotmail.com> wrote in message
news:e0**************************@posting.google.c om...
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
Nov 20 '05 #2

P: n/a
Thanks Ken,

This code works good, it does not work with images with links
associated to them it there a way around this. Please let me know
Thanks,

William


"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message news:<uz**************@TK2MSFTNGP09.phx.gbl>...
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

--------------------------

"William" <bk******@hotmail.com> wrote in message
news:e0**************************@posting.google.c om...
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

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.