I am trying to have a check box (notTodayCheckBox
) that if the datetimepicker (DateTimePicker
) has a selection of today it isn't checked, if the selection is not today it is checked.
My current code ticks the box if the date selected isn't today, but if I change it back to today the box doesn't uncheck.
Current Code:
private void DateTimePicker_ValueChanged(object sender, EventArgs e)
{
DateTime check;
if (DateTime.TryParse(dateTimePicker.Text, out check) && check != DateTime.Now)
{
notTodayCheckBox.Checked = true;
}
else if (DateTime.TryParse(dateTimePicker.Text, out check) && check == DateTime.Now)
{
notTodayCheckBox.Checked = false;
}
}
Aucun commentaire:
Enregistrer un commentaire