如何在控件不可见时保存PictureBox图像?

时间:2012-06-25 13:44:20

标签: c# .net .net-2.0

所以这是保存的代码:

    private void saveToolStripMenuItem_Click(object sender, EventArgs e)
    {

        SaveFileDialog saveFileDialog1 = new SaveFileDialog();
        saveFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments);
        saveFileDialog1.Filter = "Bitmap (*.BMP)|*.bmp|All Files (*.*)|*.*";
        saveFileDialog1.FilterIndex = 1;

        if (pictureBox1.Image != null)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.Image.Save(saveFileDialog1.FileName);

                MessageBox.Show("Vasa slika je uspjesno spremljena");

            }
        }

    }   
当它不可见时,

pictureBox1.Image == null。就像它不可见时不存在一样。

pictureBox1.Image包含我的图像,但出于设计原因,它不能显示。是否有任何简单的方法可以在不可见时保存它,或者在可见时将它隐藏在程序窗口后面?

0 个答案:

没有答案