在PictureBox中显示来自互联网的图像(C#) [英] display image from the internet in a PictureBox (C#)

查看:58
本文介绍了在PictureBox中显示来自互联网的图像(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。我试图将图像从网络显示到图片框控件。当表单加载时,我希望pictureBox控件从文本框控件中读取URL并加载图像。我找到VB等效代码来做这个,但我是一个新手,不能把它翻译成C#:

Hi all. Im trying to display images from the web into a picturebox control. when the form loads, i'd like for the pictureBox control to read a URL from a textbox control and load the image. i found the VB equivalent code to do this but im a newbie and cant translate it into C#:

PictureBox1.Image = 系统.Drawing.Bitmap( New IO.MemoryStream( New System.Net.WebClient()。DownloadData(TextBox1.Text )))//假设在表单上有一个名为textbox1的文本框和一个名为picturebox1的图片框。 Textbox1.text应该是图片的网址。

PictureBox1.Image = New System.Drawing.Bitmap(New IO.MemoryStream(New System.Net.WebClient().DownloadData(TextBox1.Text)))  // Assumes there is a textbox called textbox1 and a picturebox called picturebox1 on a form. Textbox1.text should be the URL of the picture.

有没有更简单的方法来解决这个问题?任何帮助表示赞赏。提前致谢

Is there an easier way to go about this? Any help is appreciated. Thanks in advance

Jason

推荐答案

怎么样

pictureBox1.ImageLocation = t extBox1.Text ;

pictureBox1.Load(textBox1.Text ); ?

Andrej


这篇关于在PictureBox中显示来自互联网的图像(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆