I am using numericupdown controls, one for setting the minimum range and other for the maximum range. User removes the entire value present in the minimum range numeric updown by pressing delete key or backspace key and moves to the maximumrange, now in the minimum range numericupdown a default value to be displayed. Fo开发者_JAVA技巧r this I am listening to the LostFocus events and assigning the values , but the values are not displayed. How to display the values in this case.
private void numericUpDown1_Leave(object sender, EventArgs e)
{
if (numericUpDown1.Controls[1].Text == String.Empty)
{
numericUpDown1.Controls[1].Text = numericUpDown1.Minimum.ToString();
numericUpDown1.Value = numericUpDown1.Minimum;
}
}
Does this answer your question?
if (numericUpDown1.Text == String.Empty) {
numericUpDown1.Text = numericUpDown1.Minimum.ToString();
numericUpDown1.Value = numericUpDown1.Minimum;
}
精彩评论