簡體   English   中英

檢查圖片框值是否為空

[英]Check the Picture box value is null or not

我使用Visual Studio IDE開發了一個可視化的C#窗體應用程序。

我的問題是如何檢查用戶是否選擇了圖像。

我粗略地檢查圖像像一個字符串,整數對象,但它不起作用

if(myPictureBox.Image == NULL){
    //The Image is Null
}

你可以這樣檢查一下

bool isNullOrEmpty = myPictureBox == null || myPictureBox.Image == null;

或者您可以創建自己的擴展方法

public static bool IsNullOrEmpty(this PictureBox pb)
{
    return pb == null || pb.Image == null;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM