![](/img/trans.png)
[英]C# Windows Forms DateTimePicker, how to get the SelectedText, SelectionStart, and SelectionLength?
[英]How can i get the selected DateTimePicker Value to the Excel cell using C# in Windows Forms
有人可以为我建议正确的代码吗? 我尝试了:
Range("A1").Value = UserForm1.DTPicker1.Value
但这不起作用。
它返回DateTime
,因此您应该使用ToString()
方法将其转换为String
。
Range("A1").Value = UserForm1.DTPicker1.Value.ToString();
尝试将您的代码放入DateTimePicker
ValueChanged
事件中:
private void DTPicker1_ValueChanged(Object sender, EventArgs e) {
Range("A1").Value = UserForm1.DTPicker1.Value;
}
在这里查看更多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.