Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi I am using date time picker this is a code

C#
string s = "2011-06-16T05:07:57+0000";

C#
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
    DateTime theDateA = DateTime.Parse(s);

    if (Convert.ToDateTime(dateTimePicker1.Text)> theDateA)
    {
        MessageBox.Show("ERROR");
    }
}


why i am finding continuous error when it fullfills the condition, it should display once only
any suggestion?
Posted
Updated 28-Aug-11 20:57pm
v3

1 solution

There has to be something which is changing the selected value in the DateTimePicker. That's why the event gets fired again. Check the call stack if it shows anything.

Use SelectedValue and not Text property for DateTimePicker.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900