C#中如何判断picturebox有无图片?

解决方案 »

  1.   

    if (pictureBox.Image != null)
    {
        //有图片
    }
    else
    {
        //无图片
    }
      

  2.   

    判断这个干嘛?
    如果你是要做,如果没图片就给它一个特定的图片的话,用不着判断在onerror里写句话就行了:
    onerror="javascript:this.src='none.gif'"
      

  3.   

    <img src='...' onerror='...'>
      

  4.   

    if(pictureBox.Image != null)
      

  5.   

    pictureBox.Image 没图片的话其值为null
      

  6.   

    picturebox的image为空不一定没图片吧?使用api画上去的行不行?