increase the DateTimePicker.dateValue
I am using the DateTimePicker
Now, how do I increase the dateValue by click on the 开发者_高级运维Button
EX:
dtp.DateValue = 1999/8/20
click on Button ----------> dtp.DateValue = dtp.DateValue + x
x is: (number)
thanks
Try
dateTimePicker1.Value = dateTimePicker1.Value.AddDays(1);
if you want to add days then you need to use AddDays and others methods are
AddHours Method
AddMilliseconds Method
AddMinutes Method
AddMonths Method
AddSeconds Method
AddTicks Method
AddYears Method
method in value of datetimepicker control
If dtp.DateValue is string of format like "6/15/2009 1:45:30 PM" then this should work
dtp.DateValue = DateTime.Parse(dtp.DateValue).AddDays(10).ToString()
Otherwise you would have to post your date string format.
Try:
DateTimePicker1.Value = DateTimePicker1.Value.AddDays(1)
UPDATE
Can this help you
DateTime dt = new DateTime();
dt = Convert.ToDateTime(dateTimePicker1.DateValue);
dt=dt.AddDays(1);
dateTimePicker1.DateValue= dt.ToString("dd-MM-yyyy");
It can be done. Increase the date by pressing the button.
private void btn_increment_Click(object sender, EventArgs e)
{
DateTime dt = new DateTime();
dt = Convert.ToDateTime(dateTimePicker1.Value);
dt = dt.AddDays(0);
dateTimePicker1.Value = dt.AddDays(1);
}
精彩评论