Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8215029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:39:15+00:00 2026-06-07T11:39:15+00:00

I would expect that my code below would, in the event I selected 8/6/2012

  • 0

I would expect that my code below would, in the event I selected 8/6/2012 in dtpWeek1, move dtpWeek2 to 8/13, dtpWeek3 to 8/20, etc.

However, no matter what I select in dtp1, it moves dtp2 to one week past the first of the month (IOW, it’s always the 8th). The rest of the DatePickers (from dtp3 through dtp9) work fine, in that they are one week beyond the previous one – but are not what they should be based on what I selected in dtp1, as they are always the 15th, 22nd, and 29th (except in most Februarys).

It’s as if when I move to another month DisplayDate changes to /1/ (which is not entirely illogical/surprising), but when I then click on a specific date within that month (such as the 6th), it disregards it.

Am I using the wrong event? The wrong methodology?

private void dtpWeek1_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
{
    dtpWeek2.DisplayDate = dtpWeek1.DisplayDate.AddDays(7);
    dtpWeek3.DisplayDate = dtpWeek1.DisplayDate.AddDays(14);
    dtpWeek4.DisplayDate = dtpWeek1.DisplayDate.AddDays(21);
    dtpWeek5.DisplayDate = dtpWeek1.DisplayDate.AddDays(28);
    dtpWeek6.DisplayDate = dtpWeek1.DisplayDate.AddDays(35);
    dtpWeek7.DisplayDate = dtpWeek1.DisplayDate.AddDays(42);
    dtpWeek8.DisplayDate = dtpWeek1.DisplayDate.AddDays(49);
    // TODO: Only add week 9 if it is within the month following the first month
    dtpWeek9.DisplayDate = dtpWeek1.DisplayDate.AddDays(56);
}

Additionally, all of the DatePicker components that have their DisplayDates programmatically assigned continue to display “Select a date” – based on the property name (DisplayDate), I would expect them to actually display their DisplayDate. Why don’t they? How can I get them to actually do so? If I click them to drop them down, I see there date is as described above (the 8th, 15th, etc.) but why are they hiding their “light” that way?

Finally, on a side note, what would be the ramifications of writing the code this way instead (I’m thinking this might be slower or even unreliable):

private void dtpWeek1_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
{
    dtpWeek2.DisplayDate = dtpWeek1.DisplayDate.AddDays(7);
    dtpWeek3.DisplayDate = dtpWeek2.DisplayDate.AddDays(7);
    dtpWeek4.DisplayDate = dtpWeek3.DisplayDate.AddDays(7);
    dtpWeek5.DisplayDate = dtpWeek4.DisplayDate.AddDays(7);
    dtpWeek6.DisplayDate = dtpWeek5.DisplayDate.AddDays(7);
    dtpWeek7.DisplayDate = dtpWeek6.DisplayDate.AddDays(7);
    dtpWeek8.DisplayDate = dtpWeek7.DisplayDate.AddDays(7);
    dtpWeek9.DisplayDate = dtpWeek8.DisplayDate.AddDays(7);
}

Changing the code to this:

    dtpWeek2.SelectedDate = dtpWeek1.DisplayDate.AddDays(7);
    dtpWeek3.SelectedDate = dtpWeek1.DisplayDate.AddDays(14);
    dtpWeek4.SelectedDate = dtpWeek1.DisplayDate.AddDays(21);
    dtpWeek5.SelectedDate = dtpWeek1.DisplayDate.AddDays(28);
    dtpWeek6.SelectedDate = dtpWeek1.DisplayDate.AddDays(35);
    dtpWeek7.SelectedDate = dtpWeek1.DisplayDate.AddDays(42);
    dtpWeek8.SelectedDate = dtpWeek1.DisplayDate.AddDays(49);
    dtpWeek9.SelectedDate = dtpWeek1.DisplayDate.AddDays(56);

Solved the problem with the dates not displaying. However, they still act as if I selected 8/1 instead of 8/6. The values are:

8/6
8/8
8/15
8/22
8/29
etc.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:39:16+00:00Added an answer on June 7, 2026 at 11:39 am

    Ok, to turn the comments into an answer: The SelectedDate property should be used like this:

    dtpWeek2.SelectedDate = dtpWeek1.SelectedDate.Value.AddDays(7);
    

    SelectedDate is a DateTime? (nullable) hence the .Value on the right hand side.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why does the following code return the output below? I would expect that 2
Consider the following code: int i = 3 << 65; I would expect that
I recently wrote code that didnt work as i would expect, it was: message
One would expect that even though strings are immutable, value-equality and reference-equality would not
I'm using NUnit mocks and would like to specify that I expect a call
I would expect the following code to throw a ParseException, but it is 2
I would expect the following code snippet to complain about trying to assign something
I would expect the following code to start my slider at '30' in it's
Note: Please note that the code below is essentially non-sense, and just for illustration
I ran into some (production!) code that looks like the snippet below: synchronized(some_object) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.