//Validate Width Values using Constraint private void textBox2_Validating(object sender, CancelEventArgs e) { if (int.TryParse(WidthField.Text, out int WidthInput) == true) { if (WidthInput < Desk.MINWIDTH || WidthInput > Desk.MAXWIDTH) { MessageBox.Show("Please enter a width from " + Desk.MINWIDTH + " to " + Desk.MAXWIDTH + " inches"); WidthField.Text = String.Empty; WidthField.BackColor = Color.Red; WidthField.Focus(); } else { WidthField.BackColor = System.Drawing.SystemColors.Window; } } else if (int.TryParse(WidthField.Text, out WidthInput) == false && WidthField.Text.Length != 0) { MessageBox.Show("Please enter a number"); WidthField.Text = String.Empty; WidthField.BackColor = Color.Red; WidthField.Focus(); } else { WidthField.BackColor = System.Drawing.SystemColors.Window; } }
void ReleaseDesignerOutlets() { if (XField != null) { XField.Dispose(); XField = null; } if (YField != null) { YField.Dispose(); YField = null; } if (WidthField != null) { WidthField.Dispose(); WidthField = null; } if (HeightField != null) { HeightField.Dispose(); HeightField = null; } }