Tech Super
Tech Super

Reputation: 51

How to change the datetimepicker value automatically while in progress

I want to know is there any way to change the datetimpePicker value while in progress.

I am using this code to go the next day .

                DateTime stdate = new DateTime();
                stdate = dateTimePicker1.Value;

                while (stdate <= DateTime.Now)
                {
                    txtSelectedDate.Text = stdate.ToString("yyyyMMdd");
                    selectedDate = Convert.ToInt32(txtSelectedDate.Text);
                    stdate = stdate.AddDays(1);
                }

I want to change the datetimepicker value while in progress automatically because my my code works on date value if i select the date which is not present in the files it does not works , if i change the datetimepicker value which the file haves it works fine.

I want to change the datetimepicker value while in progress automatically.

There would be great appreciation if someone coulde help me.

Thanks In Advance.

Upvotes: 1

Views: 3035

Answers (1)

Waleed
Waleed

Reputation: 3145

I'm not sure if I've understood your question but if you're looking to update the DateTimePicker after each increment, you just need to affect its Value property, something like this:

stdate = stdate.AddDays(1);
dateTimePicker1.Value = stdate;

Upvotes: 2

Related Questions