【发布时间】:2021-09-07 13:53:27
【问题描述】:
我一直在使用 2 个表单构建我的应用程序,一个 Home 表单和一个用于显示图像的单独表单。它使用 OpenFileDialog 并过滤掉文件以供选择。但是,我如何实际引用另一个表单本身的图片框?
// open file dialog
OpenFileDialog open = new OpenFileDialog();
// image filters
open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
if (open.ShowDialog() == DialogResult.OK) {
// display image in picture box
// How to change this to access pictureBox1 on Form2
pictureBox1.Image = new Bitmap(open.FileName);
上面的脚本是通过按钮执行的。再次如何从Form2中引用pictureBox?
【问题讨论】:
标签: c# image winforms picturebox