我 打开图像我尝试了这种方法但是当我点击按钮时窗口不会出现 所以我无法加载图像
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
if (open.ShowDialog() == DialogResult.OK)
{
pictureBox1.ImageLocation = open.FileName;
}
答案 0 :(得分:0)
这样做可以完美地显示完整的图像。
private void button1_Click_1(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
if (open.ShowDialog() == DialogResult.OK)
{
pictureBox1.ImageLocation = open.FileName;
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
}
}
答案 1 :(得分:-1)
有" Open"和"取消" OpenfileDialog上的按钮。因为没有" OK"按钮,"如果条件"不会是真的。你应该把它改成:
Private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
if (open.ShowDialog() != DialogResult.Cancel)
{
pictureBox1.ImageLocation = open.FileName;
}
}