private void StartNumberTextBox_TextChanged(object sender, EventArgs e) { StartNumberTBErrorProvider.Clear(); try { startNumber = Int32.Parse(StartNumberTextBox.Text); } catch (Exception ex) { StartNumberTBErrorProvider.SetError(StartNumberTextBox, ex.Message); } }
//parsing the text from controls in order to set an error message to the rigth control if there is incorrect data in that control private int TextBoxTextParse(Control control) { int retValue = 0; try { retValue = Int32.Parse(control.Text); } catch (Exception ex) { StartNumberTBErrorProvider.SetError(control, ex.Message); } return(retValue); }