How to change the Appearance of MonthCalendar Control

In this article we will learn that how to customize MonthCalendar control. We can set the various color schemes, fonts and other appearance.

How to set the MonthCalendar’s color scheme

You can set the various properties such as TrailingForeColor,TitleForeColor and TitleBackColor.
TrailingForeColor : You can change background color of the title area of the calendar.
TitleForeColor : You can change the foreground color of the title area of the calendar.
TitleBackColor : You can change the color of days in months that are not fully displayed in the control.
ForeColor : You can change the color used to display text within month.

You can set these property either in code or in the Properties window.

[VB.net]

MonthCalendar1.TitleBackColor = System.Drawing.Color.Maroon
MonthCalendar1.TrailingForeColor = System.Drawing.Color.Red
MonthCalendar1.TitleForeColor = System.Drawing.Color.Yellow
MonthCalendar1.ForeColor =System.Drawing.Color.Blue

[C#.net]

monthCalendar1.TitleBackColor = System.Drawing.Color.Maroon;
monthCalendar1.TrailingForeColor = System.Drawing.Color.Yellow;
monthCalendar1.TitleForeColor = System.Drawing.Color.Red;
monthCalendar1.ForeColor = System.Drawing.Color.Blue;

Note: It may be happen that these properties might not change the appearance of the calendar. This is because MonthCalendar is rendered with an appearance that is derived at run time from the current operating system theme.But you can disable visual styles for your application. To disable visual styles in Visual Basic, open the Project Designer and uncheck the Enable XP visual styles check box.

How to display the current date at the bottom of the control

[VB.net]

MonthCalendar1.ShowToday = Not MonthCalendar1.ShowToday

[C#.net]

monthCalendar1.ShowToday = !monthCalendar1.ShowToday;

How to show week numbers

ShowWeekNumbers property indicates whether the month calendar control will display week numbers ( 1 to 52) to the left of each row of the days.You can set this property either in code or in the Properties window.
[Vb.net]

MonthCalendar1.ShowWeekNumbers = True

[C#.net]

monthCalendar1.ShowWeekNumbers = true;

4 thoughts on “How to change the Appearance of MonthCalendar Control”

  1. In C#.net i want to display & control only a range of date in monthCalendar to the user
    eg: DateTime.Now() + 30days rest of the date should must be hiden

  2. hello Dean

    From following code you can set the min and max date for the month Calendar control

    try this code:

    MonthCalendar1.MinDate = DateTime.Now();
    MonthCalendar1.MaxDate = DateTime.Now().AddDays(30);

  3. Hello Dean

    please reply me about this is working fine or not, if not then i will provide you another solution…

     

    thanks

  4. great! I made that when i click on a date, i can make an appoinment. I just want to know how to get that date number on the month calendar in bold? so i know that there is an appointment.

Comments are closed.