Teron Kee Teron Kee - 2 months ago 27
C# Question

Image in picturebox by image path url

How do i get the image to be shown in winform after the url is typed / keyed into the textbox ? Below method applies for browsing image and then it'll appear in the combo box , Is there any other methods? as i've search for multiple it just doesn't work

OpenFileDialog OpenFd = new OpenFileDialog();
OpenFd.Filter = "Images only. |*.jpg; *.jpeg; *.png; *.gif;";

DialogResult dr = OpenFd.ShowDialog();
pictureBox2.Image = Image.FromFile(OpenFd.FileName);
textBox1.Text = OpenFd.FileName;

Answer
private void yourTextBox_TextChanged(object sender, EventArgs e)
    {
        if (System.IO.File.Exists(yourTextBox.Text))
            pictureBox.Image = Image.FromFile(yourTextBox.Text);
    }

use TextChanged event of your TextBox