R
Randy
Based on the date that the user selects, I'm trying to make the
MonthCalendar control highlight the entire week. In my case, the week
is from Monday - Sunday. I thought that using AddBoldedDate along
with selectionrange.start and .end would accomplish this, but it
doesn't.
Here is my code:
Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles
MonthCalendar1.DateChanged
Dim dateToday As Date = MonthCalendar1.SelectionRange.Start
Dim LastMonday As Date
Select Case dateToday.DayOfWeek
Case DayOfWeek.Monday
LastMonday = MonthCalendar1.SelectionRange.Start
Case DayOfWeek.Tuesday
LastMonday =
MonthCalendar1.SelectionRange.Start.AddDays(-1)
Case DayOfWeek.Wednesday
LastMonday =
MonthCalendar1.SelectionRange.Start.AddDays(-2)
Case DayOfWeek.Thursday
LastMonday =
MonthCalendar1.SelectionRange.Start.AddDays(-3)
Case DayOfWeek.Friday
LastMonday =
MonthCalendar1.SelectionRange.Start.AddDays(-4)
Case DayOfWeek.Saturday
LastMonday =
MonthCalendar1.SelectionRange.Start.AddDays(-5)
Case DayOfWeek.Sunday
LastMonday =
MonthCalendar1.SelectionRange.Start.AddDays(-6)
End Select
With MonthCalendar1
.SelectionRange.Start = LastMonday
.SelectionRange.End = LastMonday.AddDays(7)
for x = 0 to 6
.AddBoldedDate(LastMonday.AddDays(x))
next
End With
End Sub
Thanks,
Randy
MonthCalendar control highlight the entire week. In my case, the week
is from Monday - Sunday. I thought that using AddBoldedDate along
with selectionrange.start and .end would accomplish this, but it
doesn't.
Here is my code:
Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles
MonthCalendar1.DateChanged
Dim dateToday As Date = MonthCalendar1.SelectionRange.Start
Dim LastMonday As Date
Select Case dateToday.DayOfWeek
Case DayOfWeek.Monday
LastMonday = MonthCalendar1.SelectionRange.Start
Case DayOfWeek.Tuesday
LastMonday =
MonthCalendar1.SelectionRange.Start.AddDays(-1)
Case DayOfWeek.Wednesday
LastMonday =
MonthCalendar1.SelectionRange.Start.AddDays(-2)
Case DayOfWeek.Thursday
LastMonday =
MonthCalendar1.SelectionRange.Start.AddDays(-3)
Case DayOfWeek.Friday
LastMonday =
MonthCalendar1.SelectionRange.Start.AddDays(-4)
Case DayOfWeek.Saturday
LastMonday =
MonthCalendar1.SelectionRange.Start.AddDays(-5)
Case DayOfWeek.Sunday
LastMonday =
MonthCalendar1.SelectionRange.Start.AddDays(-6)
End Select
With MonthCalendar1
.SelectionRange.Start = LastMonday
.SelectionRange.End = LastMonday.AddDays(7)
for x = 0 to 6
.AddBoldedDate(LastMonday.AddDays(x))
next
End With
End Sub
Thanks,
Randy