Solved

VB 2005 Calendar Control

Posted on 2007-11-30
2
533 Views
Last Modified: 2010-04-21
In VB is there a way to bold dates on the calendar through code based on dates in an Access database?
0
Comment
Question by:MyTime2Live
2 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 20388295
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
 

Author Closing Comment

by:MyTime2Live
ID: 31412075
Thank you.  This worked.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now