hi there,
i have two datetime picker in the form that i have created. i added the below code for the datetime picker.one dpSDate and the other dpEDate.
private void dpStartD_Validating(object sender, CancelEventArgs e)
{
if (dpStartD.Value < System.DateTime.Now.Date)
{
dpStartD.Value = System.DateTime.Now;
MessageBox.Show("Enter a valid date for start date");
}
}
private void dpEndD_Validating(object sender, CancelEventArgs e)
{
if (dpEndD.Value > System.DateTime.Now.Date)
{
dpStartD.Value = System.DateTime.Now;
MessageBox.Show("Enter a valid date end date");
}
if (dpStartD.Value > dpEndD.Value)
{
dpStartD.Value = System.DateTime.Now;
MessageBox.Show("End date should be greater than the start date");
}
}
when i click the date from the datetimepicker and click the date that was a previous date it should give me and error after i click and finish.
but when i click the date the error msg dosen't come as soon i have finish clicking the date. i have to click some where else to display the error msg
how can i change the code so that when i finish selecting a value from the datetime picker the error msg to display
how can i do this
thanx