开发者

Overriding DateTimePicker Arrow Key Functionality?

开发者 https://www.devze.com 2023-03-14 07:38 出处:网络
I was wondering whether it\'s possible to override the arrow key functionality that is built into DateTimePickers.For instance, if you select a DateTimePicker and have the month highlighted, if you pr

I was wondering whether it's possible to override the arrow key functionality that is built into DateTimePickers. For instance, if you select a DateTimePicker and have the month highlighted, if you press up or down, it changes the month up or down.

I want to get rid开发者_如何学Python of all of this and put my own code in there. Any help would be very much appreciated!


Handle the key stroke event for the date picker.

Drop a dateTimePicker on a form. Add a KeyDown event.

The code below essentially disables the arrow keys for the date time picker.

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

Not sure what you want to do, but handle the event however you choose and then mark it as handled.

0

精彩评论

暂无评论...
验证码 换一张
取 消