Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

How can I populate a Picturebox control with an image from a known location on the internet with VB .NET?

 

For example, if I click a button and wanted to populate the Picturebox control with the Extreme .NET Forums logo from the top of this page, I would want the code to go out and load the image that can be found at http://www.xtremedotnettalk.com/images/logo.gif

 

Can someone show me a blurb of code that would do this?

 

Thanks,

 

Himey

  • *Gurus*
Posted

Assuming you have a picturebox on your form called PictureBox1...

 

       Dim wc As New System.Net.WebClient()
       Dim bdata() As Byte
       Dim ms As MemoryStream

       bdata = wc.DownloadData("http://www.xtremedotnettalk.com/images/logo.gif")
       ms = New MemoryStream(bdata)

       PictureBox1.Image = Bitmap.FromStream(ms)

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Excellent advice. Works perfectly. Thank you very much.

 

I figured it had to do with streams, but I hadn't checked the memory stream.

  • *Experts*
Posted

/bows before the almighty divil :)

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...