1
votes

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. For 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.

2
Dont forget to accept an answer if it worked :).Webleeuw

2 Answers

1
votes

        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;
            }
        }
0
votes

Does this answer your question?

if (numericUpDown1.Text == String.Empty) {
    numericUpDown1.Text = numericUpDown1.Minimum.ToString();
    numericUpDown1.Value = numericUpDown1.Minimum;
}