himey Posted January 28, 2003 Posted January 28, 2003 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 Quote
*Gurus* divil Posted January 28, 2003 *Gurus* Posted January 28, 2003 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) Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
himey Posted January 28, 2003 Author Posted January 28, 2003 Excellent advice. Works perfectly. Thank you very much. I figured it had to do with streams, but I hadn't checked the memory stream. Quote
*Experts* Nerseus Posted January 28, 2003 *Experts* Posted January 28, 2003 /bows before the almighty divil :) -ner Quote "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
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.