为什么图片框显示不出图片了呢?(附代码)
新手自学
          private Bitmap srcBitmap = null;
          private Bitmap showBitmap = null;
        private void button1_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                if (folderBrowserDialog1.SelectedPath.Trim() != "")
                    textBox1.Text = folderBrowserDialog1.SelectedPath.Trim();
            DirectoryInfo di = new DirectoryInfo(textBox1.Text);
            listBox1.Items.AddRange(di.GetFileSystemInfos());
        }
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            srcBitmap = (Bitmap)Bitmap.FromFile(folderBrowserDialog1.SelectedPath + "\\" + listBox1.SelectedItem.ToString(), false);
            showBitmap = srcBitmap;
            pictureBox1.ImageLocation = listBox1.SelectedItem.ToString();
            this.Invalidate();        }

解决方案 »

  1.   

    pictureBox1.image=.......
    这句话那里去了?
      

  2.   

    同意楼上。另外,this.Invalidate();这句是不是必须的?
      

  3.   

    pictureBox1.ImageLocation = listBox1.SelectedItem.ToString();
    是这句话有问题
    在另一个程序中这么写是可以读出来的,不过在这里需换成pictureBox1.image=.才行,为什么呢?
      

  4.   

    Image  获取或设置 PictureBox 显示的图像。  
      ImageLocation  获取或设置要在 PictureBox 中显示的图像的路径。