我希望我的datetimepicker在此处提出相同的行为: Move to Following Date Part on Data Entry in DateTimePicker
要把它放在这里,我希望在输入日期或月份后移动到下一个日期部分。
但我不使用Telerik,我不希望在ValueChanged事件中使用SendKey,就像这个解决方案一样: Avoid pressing . (period) key to move to next field in DateTime picker control
因为我得到InvalidOperationException。 如果可能的话,我不希望像这样创建自己的控件: DateTimePicker automatically move to next datepart
如果不够清楚,链接的解决方案对我来说效果不好,所以我要求其他解决方案(如果存在的话)。谢谢。
答案 0 :(得分:1)
尝试使用链接此链接。将文本框添加到TextChange方法。
private void B_TextChanged(object sender, TextChangedEventArgs e)
{
TextBox t = (TextBox)sender;
string seperator = "/";
switch(e.NewTextValue.Length)
{
case 2:
t.Text += seperator;
break;
case 5:
t.Text += seperator;
break;
case 10:
t.Text += seperator;
break;
}
}