コード例 #1
0
        private void ImageButton_Click(object sender, EventArgs e)
        {
            Image img;

            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Title  = "Select image to open";
                ofd.Filter = "Images|*.png;*.jpg";
                if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }
                else
                {
                    img = Image.FromFile(ofd.FileName);
                }
            }
            ImageDisplay imd = new ImageDisplay(img);

            imd.Show();
        }
コード例 #2
0
 private void ImageButton_Click(object sender, EventArgs e)
 {
     Image img;
     using (OpenFileDialog ofd = new OpenFileDialog())
     {
         ofd.Title = "Select image to open";
         ofd.Filter = "Images|*.png;*.jpg";
         if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
             return;
         else
             img = Image.FromFile(ofd.FileName);
     }
     ImageDisplay imd = new ImageDisplay(img);
     imd.Show();
 }