Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Paddy
|
Jan 12, 2011 - 10:39 PM
|
Hi,
I have a DateTimePicker on my form and would like to add seven days to the value.
Usually, you would do: DateTimePicker1.Value = DateTimePicker1.Value.AddDays(7) However, when I get to .Value, .AddDays isn’t an available option. How do I goabout adding days to the default value?
Thanks!
|
|
Technical Support
|
Jan 13, 2011 - 4:56 AM
|
The DateTimePicker.Value property is a nullable value, so you should use it like as follows: if (DateTimePicker1.Value.HasValue)
{
DateTimePicker1.Value = DateTimePicker1.Value.Value.AddDays(7);
}
else
{
DateTimePicker1.Value = DateTime.Now;
}
|
|
Paddy
|
Jan 13, 2011 - 9:19 AM
|
|
|