将重点放在日期字段DateTimePicker控件的Windows窗体放在、窗体、字段、控件

2023-09-06 19:35:45 作者:逃不开他是身体扩散的癌

我在我的code进行的DateTimePicker 控制。我已经使用了自定义格式。

I've a DateTimePicker control in my code. And I have used a custom format.

this.dateTimePickerDate.CustomFormat = "dd/MM/yyyy";
this.dateTimePickerDate.Value = System.DateTime.Now;

现在的要求是把重点放在控制的日期部分。例如,如果该控件显示30/06/2011,在Form_Load后,再 30 从日期部分应选择或光标会后的 0 30

Now the requirement is to focus on the date part of the control. For example if this control shows 30/06/2011, after the form_load, then 30 from the date part should be selected or the cursor will be after the 0 in 30.

在此先感谢。

推荐答案

这也许code有助于:

Maybe this code helps:

dateTimePicker1.GotFocus += new EventHandler(dateTimePicker1_GotFocus);

void dateTimePicker1_GotFocus(object sender, EventArgs e)
{
    SendKeys.Send("{RIGHT 1}");
}

和对形式的负载将焦点设置的DateTimePicker。

And on form load set focus to datetimepicker.