[英]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.