Click here to Skip to main content
12,556,931 members (52,703 online)
Click here to Skip to main content
Add your own
alternative version


631 bookmarked

A Professional Calendar/Agenda View That You Will Use

, 27 Aug 2009 LGPL3
Rate this:
Please Sign up or sign in to vote.
An Outlook style calendar view with appointments and all-day events, and multiple day view support.


As you can see in the screenshots, this is a fully capable calendar view for specifying appointments and all day events. It has several features so you can control what happens inside, like item blocking and item-oriented events.

It's 100% managed code! No resources; as with most of my projects, you can just include all the source files into your project to make it work.


I found a couple of controls like this, but as always, they don't meet my needs, so here I come. It performs fairly well, but mostly will depend on your implementation - I'll explain that in the next section.

Using the Code

To add a calendar to your form, just drag the Calendar control. It's located under the System.Widows.Forms.Calendar namespace.

When to Use it

It can be used to display any information that is based on a date, not just appointments and meetings. Think about it, on what ugly control do you display your system log?

Controlling the View

The view of the Calendar is given by a date range provided by the ViewStart and ViewEnd properties. Depending on the number of days between these two dates, the calendar will draw them.

The Calendar can show days in two modes: Expanded and Short (see Calendar.DaysMode). Expanded is the style of the first screenshot: the days are shown in a column, and items are placed in the time they belong; while the Short mode (second screenshot) shows days on week rows, and items are shown in a more compact way.

An important property here is MaximumFullDays (by default, 8). This property indicates that when you specify a view of 8 days or less, the days will be shown in Expanded mode. Any more days will be displayed in Short mode.

Feeding Items to the Calendar

The calendar tells you when to add items to it with the LoadItems event. In that event, you should manage to bring information to display in the calendar, by adding items to the Items collection of the calendar. The event is raised every time the view changes. I strongly suggest that you use caching and not query the database every time this event is raised, because performance will be severely affected.

The demo project in the source loads items from a memory array, so it's not the best example.

private void calendar1_LoadItems(object sender, CalendarLoadEventArgs e)
    //Load items whose date range intersects e.DateStart and e.DateEnd
    foreach(CalendarItem item in loadedItems)
    //Or even better....

I strongly suggest to add items that only intersect with the calendar's view range. You can learn how to check date intersection by taking a look at the implementation of DateIntersects, in Calendar:

public static bool DateIntersects(DateTime startA, DateTime endA, 
                                  DateTime startB, DateTime endB)
     //Don't forget to check dates this way in your database queries!
     return startB < endA && startA < endB;


Since you can explore other members using IntelliSense I list events here; they are important because they let you control your application of the Calendar.

  • DayHeaderClick: Occurs when a day header is clicked.
  • ItemClick: Occurs when an item is clicked.
  • ItemCreated: Occurs when an item is successfully created.
  • ItemCreating: Occurs when the user is about to create an item. It can be cancelled.
  • ItemDatesChanged: Occurs when the date range of an item changes.
  • ItemDeleted: Occurs when an item is successfully deleted.
  • ItemDeleting: Occurs when the user is about to delete an item. It can be cancelled.
  • ItemDoubleClick: Occurs when an item is double clicked.
  • ItemMouseHover: Occurs when the mouse is placed over an item.
  • ItemSelected: Occurs when an item is selected.
  • ItemTextEdited: Occurs when an item's text is edited by the user.
  • ItemTextEditing: Occurs when the user is trying to edit an item's text. It can be cancelled.
  • LoadItems: Occurs when the Calendar view is changed.

Some Nice Features

Items Overlapping

When items intersect in their date ranges, there's a nice algorithm that performs a layout to accommodate them. Give it a try.

Item Coloring

Although a Renderer takes charge of drawing items, you can specify the background colors and borders to items individually.

Even better, you can use the ApplyColor method (in CalendarItem) to an item, and the code will take charge of shading colors for the background, border, and text.

In the demo application, use the calendar's contextual menu to apply coloring to items.


You can choose between options of time scaling, though, the default is 30 minutes like Outlook's calendar. Here is a sample of a 15 minutes timescale.

In the demo application, use the calendar's contextual menu to choose different timescale options.


Don't you absolutely hate the way the MonthCalendar control behaves on your UI? Well, here is the solution. Now, the project contains a control called MonthView, which looks like the Outlook calendar's view, fully customizable, and it does not force the size of the control; the visualization of months will depend on the size of the container.

Some interesting properties of the control are:

  • FirstDayOfWeek - To change what day your weeks start with.
  • ItemPadding - To set the padding of the internal items, so you can make a compact or not so much view.
  • SelectionMode - Manual, Day, Week, WorkWeek, and Month.
  • WorkWeekStart - To specify what day the work-weeks start with.
  • WorkWeekEnd - To specify what day the work-weeks end with.


  • Aug 02 2009: First release.
  • Aug 05 2009
    • License changed to LGPL.
    • Added the FirstDayOfWeek property to change what day your weeks start with.
    • Added the Tag property to CalendarItem.
  • Aug 27 2009
    • Added minute exact indicators.
    • Added keyboard arrows support.
    • Added Image and ImageAlign properties to CalendarItem for adding images to items.
    • Added Pattern and PatternColor properties to CalendarItem for marking items with textures.
    • Added the MonthView control to have a nice calendar control.


This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


About the Author

Jose Menendez Póo
Team Leader
Mexico Mexico
I'm in game programming now:

Jose Manuel Menéndez Poó

- I've been programming Windows and Web apps since 1997.
- My greatest concern nowadays is user interface usability.

Questions and stuff by twitter: @menendezpoo


You may also be interested in...


Comments and Discussions

BugError on Demo project Pin
eduvolp4-May-16 7:57
membereduvolp4-May-16 7:57 
SuggestionRe: Error on Demo project Pin
Member 125032494-May-16 21:37
memberMember 125032494-May-16 21:37 
GeneralRe: Error on Demo project Pin
Coolzero200323-May-16 23:08
memberCoolzero200323-May-16 23:08 
QuestionCan someone please explain how to use it? Pin
Member 1242649030-Mar-16 7:39
memberMember 1242649030-Mar-16 7:39 
AnswerRe: Can someone please explain how to use it? Pin
Grant Hickey4-Apr-16 22:50
memberGrant Hickey4-Apr-16 22:50 
QuestionCalendar days Mode Pin
Keylor Bastos19-Feb-16 10:19
memberKeylor Bastos19-Feb-16 10:19 
AnswerRe: Calendar days Mode Pin
chrisbray23-Feb-16 11:09
memberchrisbray23-Feb-16 11:09 
QuestionRe: Calendar days Mode Pin
Member 125032494-May-16 21:34
memberMember 125032494-May-16 21:34 
AnswerRe: Calendar days Mode Pin
chrisbray5-May-16 1:28
memberchrisbray5-May-16 1:28 
QuestionWould it be possible to add a time indicator so you can see the time of day marked on the calendar? Pin
Member 970184919-Jan-16 3:16
memberMember 970184919-Jan-16 3:16 
AnswerRe: Would it be possible to add a time indicator so you can see the time of day marked on the calendar? Pin
Coolzero200320-May-16 11:07
memberCoolzero200320-May-16 11:07 
QuestionRe: Would it be possible to add a time indicator so you can see the time of day marked on the calendar? Pin
Alessio Vigilante5-Oct-16 23:31
memberAlessio Vigilante5-Oct-16 23:31 
QuestionPlease help with time! Pin
UrLoReaL6-Jan-16 6:52
memberUrLoReaL6-Jan-16 6:52 
AnswerRe: Please help with time! Pin
Coolzero200320-May-16 11:12
memberCoolzero200320-May-16 11:12 
QuestionHorizontal Orientation Pin
shazwaz3-Dec-15 19:59
membershazwaz3-Dec-15 19:59 
QuestionHow to change default starting time from 12.00 am to 8.00 am of calendar Pin
Vineetha Ravindranath10-Nov-15 0:16
memberVineetha Ravindranath10-Nov-15 0:16 
AnswerRe: How to change default starting time from 12.00 am to 8.00 am of calendar Pin
Member 107015995-Jan-16 7:05
memberMember 107015995-Jan-16 7:05 
AnswerRe: How to change default starting time from 12.00 am to 8.00 am of calendar Pin
Coolzero200324-May-16 3:54
memberCoolzero200324-May-16 3:54 
QuestionMessage Removed Pin
Vineetha Ravindranath10-Nov-15 0:11
memberVineetha Ravindranath10-Nov-15 0:11 
QuestionControl freezes because of unterminated loop Pin
Oliver Gramberg8-Nov-15 23:33
memberOliver Gramberg8-Nov-15 23:33 
QuestionIs it possible to change the language of the Calendar Day's and Month's? Pin
Member 118602166-Nov-15 23:44
memberMember 118602166-Nov-15 23:44 
AnswerRe: Is it possible to change the language of the Calendar Day's and Month's? Pin
Member 116368393-Dec-15 12:49
memberMember 116368393-Dec-15 12:49 
QuestionHow to make overnight appointments display better? Pin
Member 1204001226-Oct-15 6:58
memberMember 1204001226-Oct-15 6:58 
SuggestionHow to programatically add appointments from SQL Pin
Member 1190227214-Sep-15 4:07
memberMember 1190227214-Sep-15 4:07 
QuestionDrag Items Between Calendars Pin
Member 805993426-Aug-15 9:25
memberMember 805993426-Aug-15 9:25 
QuestionChange font Demo Pin
aladdid24-Aug-15 9:49
memberaladdid24-Aug-15 9:49 
QuestionMessage Removed Pin
Member 805993421-Aug-15 7:34
memberMember 805993421-Aug-15 7:34 
QuestionMessage Removed Pin
Member 805993414-Aug-15 10:07
memberMember 805993414-Aug-15 10:07 
QuestionVertical scrollbar? Problem solved Pin
Giovanni S.8-Aug-15 1:04
memberGiovanni S.8-Aug-15 1:04 
QuestionWebForm Pin
coredco6-Aug-15 13:37
membercoredco6-Aug-15 13:37 
Questionhow can i display a month in control Pin
89krzychu@gmail.com28-Jul-15 7:38
member89krzychu@gmail.com28-Jul-15 7:38 
QuestionHow do I add this to my current program Pin
Member 116720767-May-15 3:52
memberMember 116720767-May-15 3:52 Pin
Abel Barreto2-May-15 23:30
memberAbel Barreto2-May-15 23:30 
QuestionGet Date from Calendar Click Pin
GranthamJa30-Apr-15 23:37
memberGranthamJa30-Apr-15 23:37 
AnswerRe: Get Date from Calendar Click Pin
GranthamJa1-May-15 0:40
memberGranthamJa1-May-15 0:40 
GeneralRe: Get Date from Calendar Click Pin
nirav raval19-Jul-15 20:56
membernirav raval19-Jul-15 20:56 
QuestionHow to Programmatically Set CalendarView SelectedElement Pin
Jeffrey A Grunschel14-Apr-15 19:12
memberJeffrey A Grunschel14-Apr-15 19:12 
QuestionIs it possible to highlight dates on MonthView control? Pin
Kebrite11-Apr-15 11:33
memberKebrite11-Apr-15 11:33 
AnswerRe: Is it possible to highlight dates on MonthView control? Pin
nirav raval17-Jul-15 19:13
membernirav raval17-Jul-15 19:13 
GeneralRe: Is it possible to highlight dates on MonthView control? Pin
Kebrite17-Jul-15 19:18
memberKebrite17-Jul-15 19:18 
QuestionHow to remove textbox in double click event of calender Pin
GBVSivaRamKumar12-Mar-15 6:49
memberGBVSivaRamKumar12-Mar-15 6:49 
Questionkeys not working on monthview Pin
Member 1018984011-Mar-15 0:49
memberMember 1018984011-Mar-15 0:49 
QuestionVersion Visual Basic 2010 Pin
Member 115071768-Mar-15 0:31
memberMember 115071768-Mar-15 0:31 
Question[Help] SelectionMode Pin
Member 114673877-Mar-15 4:09
memberMember 114673877-Mar-15 4:09 
QuestionRuntime Exception Pin
Member 82194076-Mar-15 3:41
memberMember 82194076-Mar-15 3:41 
AnswerRe: Runtime Exception Pin
Member 1116143910-Apr-15 11:49
memberMember 1116143910-Apr-15 11:49 
Questionunmerge textbox control Pin
john belush26-Feb-15 6:08
memberjohn belush26-Feb-15 6:08 
QuestionHow to remove timescale Pin
Member 1018984020-Feb-15 19:53
memberMember 1018984020-Feb-15 19:53 
QuestionChanging background color Pin
Member 1068586420-Feb-15 8:09
memberMember 1068586420-Feb-15 8:09 
Generalayuda Pin
Member 1145978718-Feb-15 7:45
memberMember 1145978718-Feb-15 7:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161026.1 | Last Updated 27 Aug 2009
Article Copyright 2009 by Jose Menendez Póo
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid