我的输入窗口中有个COMBOBOX控件和DATETIMEPICKER控件,我想根据combobox选的选项,DATETIMEPICKER时时生成新的时间。
我在COMBOBOX控件的 VALUECHANGE 事件中输入以下代码:
Dim a As WinForm.ComboBox = e.Form.Controls("ComboBox3")
Dim b As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker1")
If a.Value="现金" Then
b.Value = Date.Today
End If
If a.Value= "月结" Then
Dim y As Integer = Date.Today.Year
Dim m As Integer = Date.Today.Month
Dim dt2 As New Date(y, m, Date.DaysInMonth(y, m)) '获取本月的最后一天
b.Value = dt2
End If
If a.Value= "月结30天" Then
Dim y As Integer = Date.Today.Year
Dim m As Integer = Date.Today.Month
Dim dt3 As New Date(y, m+1, Date.DaysInMonth(y, m+1)) '获取本月的最后一天
b.Value = dt3
End If
为什么选现金时,可以时时更新,而且选了后面这两个不会马上更新时间,但窗口重新打开时,时间又会显示出来,如果可以实现先后面这两个时间也能马上显示出来呢?