if(NumericUpDown1.Text == "")
{
// If the value in the numeric updown is an empty string, replace with 0.
NumericUpDown1.Text = "0";
}
Run Code Online (Sandbox Code Playgroud)
使用经过验证的事件并请求text属性可能很有用
private void myNumericUpDown_Validated(object sender, EventArgs e)
{
if (myNumericUpDown.Text == "")
{
myNumericUpDown.Text = "0";
}
}
Run Code Online (Sandbox Code Playgroud)