直接在C#中的DateTimePicker上转到月份和年份 [英] Go to month and year directly on DateTimePicker in C#

查看:355
本文介绍了直接在C#中的DateTimePicker上转到月份和年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户在我的 DateTimePicker 中键入日期,它将自动聚焦到月份的一部分,然后在键入后将其转到

因为我不想他必须按右键来集中注意力……有没有办法通过编程方式做到这一点?

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?

用户不可能已经点击了月份或年份部分,因为他使用键盘进行了全部操作,并集中了 DateTimePicker ,只需按TAB。

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.

格式很短: DD / MM / YYYY

有人知道吗?

推荐答案

尝试使用事件valuechanged

try using the event valuechanged

尝试以下操作:

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

这篇关于直接在C#中的DateTimePicker上转到月份和年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆