如果1个月输入文本框,那么自动设置在DATETIMEPICKER1和DATETIMEPIKER2日期

时间:2016-11-04 12:16:30

标签: vb.net datetimepicker monthcalendar

我想自动将datetimepicker设置为日期,例如我在文本框中写了1个月。那可能吗?请帮帮我们,谢谢!

1 个答案:

答案 0 :(得分:0)

您可以尝试例如:

Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
    DateTimePicker1.Value = DateTimePicker1.Value.AddMonths(Convert.ToInt32(TextBox1.Text))
End Sub

您可以使用AddDays,AddMonths或AddYears来修改dateTimePicker的值