2011-09-22 27 views
1

如何連接兩個datetimepicker的值?VS2010中的連接DateTimePicker

DateTimePicker1 - this is for the the DATE mm/dd/yyyy 
DateTimePicker2 - this is for the the TIME hh:mm:ss 

我想將... mm/dd/yyy hh:mm:ss的值放在一個變量中,我該怎麼做?

回答

1

一個簡單的方法是

DateTime dt = new DateTime(dtp1.Year, dtp1.Month, dtp1.Day, dtp2.Hour, dtp2.Minute, dtp2.Second); 

請檢查參數的,我從存儲器寫入順序。 這裏dtp1是第一個日期時間選擇器的DateTime對象。

+0

昏暗ArrivalDate作爲日期=新日期時間(dtp_ArrivalDate.Value.Year,dtp_ArrivalDate.Value.Month,dtp_ArrivalDate.Value.Day,dtp_ArrivalTime.Value.Hour,dtp_ArrivalTime.Value.Minute,dtp_ArrivalTime.Value.Second) –