Paul Loughridge

Paul Loughridge

  • NA
  • 109
  • 44.6k

User Control

Mar 17 2008 3:30 PM

I have a User Control which has a PictureBox with an Image Property.
When the control is placed on the MainForm it no longer has an Image Property. The MainForm has an openFileDialog control.

The code:

 private void OpenImage()
  {
   try
   {
    this.openFileDialog1.ShowDialog();
                openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";

    string path = this.openFileDialog1.FileName;
    this.viewer1.Image = Image.FromFile(path);
   }
   catch
   {
                MessageBox.Show ("Invalid selection. Must be an image file", "Picture Viewer", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
            }
  }


Answers (1)