简体   繁体   中英

C# DateTimePicker, how can I detect events when up-down button was clicked?

Well I surely understand how OnValueChanged works. But I need to detect the up-down button, SPECIFICALLY, because I have a timer running back to increase the DateTimePicker automatically. If timer is stopped in 'OnValueChanged', it just stops automatically. I just want the timer to stop only when up-down button was clicked, any ideas?

Well you could just disable typing in the picker by doing something like:

private void dateTimePicker1_KeyDown(object sender, KeyEventArgs e)
{
    e.SuppressKeyPress = true;
}

This way the user would only be able to change the value using the Up / Down buttons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM