How to customize a monthcalendar in

Written by alexander gokhfeld
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to customize a monthcalendar in
VB.NET MonthCalendar control allows users to customise calendar views. (Thomas Northcut/Photodisc/Getty Images)

The Microsoft VB.NET MonthCalendar control allows users to select a date using a monthly calendar view. If you need to customise the look of the MonthCalendar control, you can change the title font, background and foreground colours of the calendar. You can also limit the date and times that you display with the MinDate and MaxDate properties of the control. By setting the "MonthCalendar.BoldedDates" property with the array of chosen values you can assign which dates will be displayed in bold.

Skill level:


  1. 1

    Click "Start" in Windows and then click "Microsoft Visual Studio."

  2. 2

    Click "File," select "Open" and then double-click on the VB.NET program in which you want to modify the MonthCalendar control.

  3. 3

    Enter the following code after the "Public Class Main ()" line to change the colour of the calendar and set the range of dates to display on the MonthCalendar control:

    Imports System

    Imports System.Windows.Forms

    Public NotInheritable Class Form1

    Inherits System.Windows.Forms.Form
    Public Shared Sub Main()
        System.Windows.Forms.Application.Run(New Form1)
    End Sub 'Main
    Public Sub New()

    ' Create the calendar.

        Me.MonthCalendar1 = New


    ' Set the calendar location.

        Me.MonthCalendar1.Location = New System.Drawing.Point

    (47, 16)

    ' Change the colour.

        Me.MonthCalendar1.BackColor =


        Me.MonthCalendar1.ForeColor =

    System.Drawing.Color.FromArgb( _

    ' Add dates to MonthlyBoldedDates array.

        Me.MonthCalendar1.MonthlyBoldedDates = New

    System.DateTime() _ {New System.DateTime(2011, 9, 15, 0, 0, 0,

    0), _ New System.DateTime(2002, 9, 30, 0, 0, 0, 0)}

    ' Sets the maximum visible date on the calendar to 12/31/2011.

        Me.MonthCalendar1.MaxDate = New System.DateTime(2011,

    12, 31, 0, 0, 0, 0)

    ' Set the minimum visible date on the calendar to 01/01/1999.

        Me.MonthCalendar1.MinDate = New System.DateTime(1999, 1,

    1, 0, 0, 0, 0)

    End Sub

    ' Show the start and end dates in the text box.

        Me.TextBox1.Text = "Date Selected: Start = " + _

    e.Start.ToShortDateString() + " : End = " +


    End Sub

    End Class

  4. 4

    Click "File" and then click "Save" to apply the change to the control in your VB.NET application.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.