如果没有文件路径,如何清空图片框 [英] how to empty the picture box if it doesnot have filepath

查看:58
本文介绍了如果没有文件路径,如何清空图片框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我有一个小问题,我找不到合适的解决方案,请帮助我

hello frens , i have a small problem and i could not find suitable solution please help me

string imagepath = dataGridView1.CurrentRow.Cells[15].Value.ToString();
          if (imagepath != null)
          {
              frm.pictureBox1.Image = Image.FromFile(imagepath);
          }
          else
          {
              frm.pictureBox1.Image = null;
          }



这并没有使我的pixturebox具有null值,而只是抛出异常

关于bishnu



this didnot get my pixturebox with null value and simply throws exception

with regards bishnu

推荐答案

使用NoImage.gif文件显示空白图片框.
take a NoImage.gif file for showing blank Picture Box.
string imagepath = dataGridView1.CurrentRow.Cells[15].Value.ToString();
                  if (imagepath != null)
                  {
                        frm.pictureBox1.Image = Image.FromFile(imagepath);
                  }
                  else
                  {
                        frm.pictureBox1.Image = Image.FromFile("path of No Image");
                  }


这篇关于如果没有文件路径,如何清空图片框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆