如何将datetimepicker2 minDate值设置为datetimepicker1日期值?

时间:2014-09-09 16:11:56

标签: vb.net

我有两个datetimepicker ..让我们说它是datetimepicker1和datetimepicker2。当我使用datetimepicker1选择日期时,datetimepicker2 mimimumdate将成为datetimepicker1的日期。在此先感谢!

1 个答案:

答案 0 :(得分:0)

这对你来说很合适。我将两个控件拖到表单上,然后在DateTimePicker1.ValueChanged Event

上执行此操作
  Private Sub DateTimePicker1_ValueChanged(sender As Object, e As System.EventArgs) Handles DateTimePicker1.ValueChanged
    DateTimePicker2.MinDate = DateTimePicker1.Value 'Set the min value
    DateTimePicker2.Value = DateTimePicker1.Value 'Set the date to second picker from the first one
  End Sub

我根本没有处理第二个DateTime控件,不知道你想用它做什么......