c# add image to form code example

Example 1: how to add image in html

<img src="pic_trulli.jpg" alt="Italian Trulli">

Example 2: how to allow user import image c#

private void cmdBrowser_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileOpen = new OpenFileDialog();
            fileOpen.Title = "Open Image file";
            fileOpen.Filter = "JPG Files (*.jpg)| *.jpg";

            if (fileOpen.ShowDialog() == DialogResult.OK)
            {
                picImage.Image = Image.FromFile(fileOpen.FileName);
            }
            fileOpen.Dispose();
        }

Example 3: how to add image in html

<img src="logo.png" />

Tags:

Html Example