• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 595
  • Last Modified:

VB 2005 Calendar Control

In VB is there a way to bold dates on the calendar through code based on dates in an Access database?
0
MyTime2Live
Asked:
MyTime2Live
1 Solution
 
Fernando SotoRetiredCommented:
Hi MyTime2Live;

Did not know if you need ASP.Net Calendar or Windows Forms MonthCalendar so I gave samples for both.

In ASP.Net you can highlight the background of the date as shown in the sample code but in Windows Form you can only Bold the dates you what to highlight as shown in the sample.

The dates I show in the sample are in an array of dates you can put you result from the database query into an array. Also in the ASP.Net version of the code there can be no time in the date time variable where in the Windows Form version that is not the case.

Fernando
ASP.Net using Visual Basic .Net
 
    Dim dates() As DateTime = {New DateTime(2007, 12, 1), New DateTime(2007, 12, 8), _
            New DateTime(2007, 12, 10), New DateTime(2007, 12, 25)}
 
    Protected Sub Calendar1_DayRender(ByVal sender As Object, _
        ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
 
        For Each dt As DateTime In dates
            If e.Day.Date = dt Then
                e.Cell.BackColor = System.Drawing.Color.Yellow
            End If
        Next
 
    End Sub
 
 
Visual Basic .Net using Windows Forms.
 
    Dim dates() As DateTime = {New DateTime(2007, 12, 1), New DateTime(2007, 12, 8), _
            New DateTime(2007, 12, 10), New DateTime(2007, 12, 25)}
 
    Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
 
        MonthCalendar1.BoldedDates = dates
 
    End Sub

Open in new window

0
 
MyTime2LiveAuthor Commented:
Thank you.  This worked.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now