I found some easy ways to load image to picturebox but I couldn’t find an easy way to load image to picturebox backround.
If you know any easier example than this…
var request = WebRequest.Create("http://www.example.com/image.jpg");
using (var response = request.GetResponse())
using (var stream = response.GetResponseStream())
{
pictureBox1.BackroundImage = Bitmap.FromStream(stream);
}
…please share it.
The two easy ways to load image from url to picturebox are…
pictureBox1.ImageLocation = "http://www.example.com/image.jpg";
pictureBox1.Load(url);
But I cannot use them
The reason that I want to use BackroundImage instead of Image is that I want to stretch the image.
If you want to strech your image to fit the PictureBox you can
PictureBox.SizeModetoStretchImage.This will work when you specify your image using the
pictureBox1.ImageLocationproperty or thepictureBox1.Load()method.