Web Image in Windows Form?

  • Thread starter Thread starter Jeff Griffin
  • Start date Start date
J

Jeff Griffin

OK, this should be my last question for the day. I have spent a couple hours
on google trying to figure this out but I probibly just dont know what I
really need to be searching for.

I have a Windows Form program that calls a web service that will return (as
a string) the full url to an image hosted on an external webserver. My
question is how do I then display this image in my form, or is this even
possible. It seems like it should be pretty simple, but I probibly just dont
know what I really need to be searching for.

Thanks Again, Jeff Griffin
 
You could invoke IE within the winform which would obviously allow you to
show the image within it, look at this
http://www.codeproject.com/csharp/winformiehost.asp?print=true and
http://blog.monstuff.com/archives/000052.html

Of course you may also be able to simply use a richtext control in your
winform from the System.Windows.Forms.RichTextBox class and reference the
image from within that, or use a picture box control as they can display
GIF's - not sure if you can point them to a URL but I expect so.

You may also find this image viewer (c# code) useful as it uses a picture
box.
http://www.dotnet247.com/247reference/a.aspx?u=http://www.c-sharpcorner.com/
winforms/ImageViewerST.asp

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
 
sfajeff2 said:
OK, this should be my last question for the day. I have spent a couple hours
on google trying to figure this out but I probibly just dont know what I
really need to be searching for.

I have a Windows Form program that calls a web service that will return (as
a string) the full url to an image hosted on an external webserver. My
question is how do I then display this image in my form, or is this even
possible. It seems like it should be pretty simple, but I probibly just dont
know what I really need to be searching for.

Thanks Again, Jeff Griffin
System.Net.WebClient source = new System.Net.WebClient();
Stream myData = source.OpenRead("http://somewhere.com/img.gif");
System.Drawing.Bitmap myPic = new System.Drawing.Bitmap(myData);

and of course all this have to be with try/catch blocks, and do not
forget to close the stream :)


Hope that helps
Sunny
 
Thank you so much yall! I will give these a try after dinner and report
back.

Jeff Griffin

PS - To everyone on these boards, keep up the great work. The speed with
which you can get a question answered here is incredible!
 
I ended up using Sunny's suggustion and it works awesome! Thank you so much!

Jeff Griffin
 
Back
Top