0

例如,我希望有一个截止日期的日期时间选择器,它总是比另一个日期时间选择器的所选日期提前两周。如果可能的话,我将如何编码?

4

1 回答 1

0

ValueChanged使用事件应该很简单。

//Tie to event to handler
dateTimePicker1.ValueChanged += new EventHandler(dateTimePicker1_ValueChanged);

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
    //Add 2 weeks to the value of your second Picker
    dateTimePicker2.Value = dateTimePicker1.Value.AddDays(14);
}
于 2013-09-30T00:52:45.330 回答