Go to month and year directly on DateTimePicker in C#

江枫思渺然 提交于 2019-12-23 16:43:21

问题


how can I achieve that if the User types in the day in my DateTimePicker it focuses automatically the month part of it, and after typing that one in it goes to the Year part?
Because I don't want him to have to press the right-key to focus it... is there a way to do this programmatically?

It is not possible that the user clicks already on the month or year part, because he does all with the keyboard, and focuses the DateTimePicker by pressing TAB.

The Format is short: DD/MM/YYYY...

Anybody knows?


回答1:


try using the event valuechanged

try this:

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
    {
        SendKeys.Send("{Right}");
    }

basically the focused part changes when you press the right arrow that code line simulate a right arrow key press



来源:https://stackoverflow.com/questions/11242033/go-to-month-and-year-directly-on-datetimepicker-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!