private void WidthNumericUpDown_Enter(object sender, EventArgs e) { { if (WidthNumericUpDown.Value == 0) { int lengthOfAnswer = WidthNumericUpDown.Value.ToString().Length; WidthNumericUpDown.Select(0, lengthOfAnswer); } } }
private void WidthNumericUpDown_Validating(object sender, CancelEventArgs e) { if (Convert.ToInt32(WidthNumericUpDown.Value) < Desk.MINWIDTH) { MessageBox.Show("You need to enter a value of at least 24 inches."); WidthNumericUpDown.Text = String.Empty; WidthNumericUpDown.Focus(); } else if (Convert.ToInt32(WidthNumericUpDown.Value) > Desk.MAXWIDTH) { MessageBox.Show("You need to enter a value equal to or less than 96 inches."); WidthNumericUpDown.Text = String.Empty; WidthNumericUpDown.Focus(); } }