![](/img/trans.png)
[英]How to check if the Value of a NumericUpDown is larger than the Year value of a DateTimePicker?
[英]Check if a NumericUpDown has no value
如何檢查用戶是否將NumericUpDown控件留空? 我在另一個問題上看到過要檢查“文本”屬性,但是沒有文本屬性可以檢查。
盡管Text
屬性對設計者和IntelliSense隱藏,但您可以對其進行檢查。
只需嘗試此示例。 它的工作原理是:
if (string.IsNullOrEmpty(control.Text))
{
// no value
}
您可以使用 ,
if(NumericUpDown.Text == "")
{
// If the value in the numeric updown is an empty string, replace with 0.
NumericUpDown.Text = "0";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.