private void txtDate_TextChanged(object sender, EventArgs e) { if (CommonFunctions.IsDate(txtDate.Text)) { try { txtDate.BackColor = Color.White; _isValid = true; } catch { txtDate.BackColor = Color.Yellow; _isValid = false; } } else if (txtDate.Text == "") { txtDate.BackColor = Color.White; _isValid = true; } else { txtDate.BackColor = Color.Yellow; _isValid = false; } }
private void LeaveDateBox(TextBox tbLeft, DateTimePicker dtpLinkedDate) { if (CommonFunctions.IsDate(tbLeft.Text)) { dtpLinkedDate.Value = Convert.ToDateTime(tbLeft.Text); tbLeft.BackColor = Color.White; } else if (tbLeft.Text == "") { tbLeft.BackColor = Color.White; } else { tbLeft.BackColor = Color.Yellow; } }