Search code examples
c#.netwinformsdatetimepicker

DateTimePicker.Value is returning an incorrect but consistent date


public void setRange(int which)       
{
    if (datelimitsset == 1)
    {
        if (startPicker.Value >= endPicker.Value && which == 1)
            // do stuff;
    }
 }

So this code simply does a datetimepicker.value to get the date. However it always returns the 1st of February when the maximum date is selected (The maximum date for my testing is 13/02/2012) Does anyone know why this might happen?


Solution

  • Used:

    private void endPicker_CloseUp(object sender, EventArgs e)

    event instead of:

    private void endPicker_ValueChanged(object sender, EventArgs e)

    This event runs once a value is selected, not before; therefore it does not default to the first of the month.