Click here to Skip to main content
12,627,681 members (32,518 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

QuestionError during deployment Pin
Ramadurai Uthami20-Jun-13 21:43
memberRamadurai Uthami20-Jun-13 21:43 
QuestionNeed some customization to the calender Pin
ash mishra18-Jun-13 20:34
memberash mishra18-Jun-13 20:34 
QuestionRe: Need some customization to the calender Pin
Ashish Khatavkar26-Mar-15 1:25
memberAshish Khatavkar26-Mar-15 1:25 
BugBug: Time is lost when multiple click Pin
sunnysunny200814-Jun-13 3:35
membersunnysunny200814-Jun-13 3:35 
GeneralRe: Bug: Time is lost when multiple click Pin
sunnysunny200814-Jun-13 5:33
membersunnysunny200814-Jun-13 5:33 
QuestionCompile Problem Pin
Member 1010526012-Jun-13 4:42
memberMember 1010526012-Jun-13 4:42 
QuestionHow can I change the scale of hours a day? Pin
Member 88710937-Jun-13 4:42
memberMember 88710937-Jun-13 4:42 
QuestionOverflow in Monthmode Pin
lsteinme6-Jun-13 3:22
memberlsteinme6-Jun-13 3:22 
BugIn the month loose calendar items at the top of the screen Pin
Paul.HulleyUSDAW5-Jun-13 4:09
memberPaul.HulleyUSDAW5-Jun-13 4:09 
QuestionHow comes the 1st September is missing? Pin
Member 100706164-Jun-13 23:48
memberMember 100706164-Jun-13 23:48 
GeneralMy vote of 5 Pin
cws2_na29-May-13 16:42
membercws2_na29-May-13 16:42 
QuestionCell click Pin
ogn1076728-May-13 23:50
memberogn1076728-May-13 23:50 
Questionshow any specified range of time Pin
binusn10-May-13 1:58
memberbinusn10-May-13 1:58 
QuestionQuestion about design Pin
garaber2-May-13 12:21
membergaraber2-May-13 12:21 
Where are the grips/anchors being set in the source. I've been digging around the CalendarItem Class and I can't find it. Thanks for any input.
Questionhow to watch the hour and minutes of all item headers? Pin
Member 939332825-Apr-13 1:43
memberMember 939332825-Apr-13 1:43 
QuestionBackGround Color Pin
tdqwerty23-Apr-13 22:27
membertdqwerty23-Apr-13 22:27 
Generalintellectual property ? Pin
jo_ie.8-Apr-13 20:26
memberjo_ie.8-Apr-13 20:26 
GeneralRe: intellectual property ? Pin
Jose Menendez Póo7-Jun-13 6:03
memberJose Menendez Póo7-Jun-13 6:03 
QuestionSmall Bug in Polish Localization Pin
oggyC#6-Apr-13 9:06
memberoggyC#6-Apr-13 9:06 
QuestionHighlightRanges in CalendarDaysMode.Short Pin
Member 86979614-Apr-13 1:58
memberMember 86979614-Apr-13 1:58 
Questiondrag and drop between two calendars?? Pin
Member 992793024-Mar-13 9:30
memberMember 992793024-Mar-13 9:30 
QuestionItem on top of day Pin
Member 992793022-Mar-13 4:05
memberMember 992793022-Mar-13 4:05 
AnswerRe: Item on top of day Pin
Pyloz22-Mar-13 12:47
memberPyloz22-Mar-13 12:47 
GeneralRe: Item on top of day Pin
Member 992793024-Mar-13 9:26
memberMember 992793024-Mar-13 9:26 
GeneralMy vote of 5 Pin
Luca Leonardo Scorcia18-Mar-13 12:53
memberLuca Leonardo Scorcia18-Mar-13 12:53 
Questionat runtime, change the displayed day to say march 20 Pin
jenia.ivlev9-Mar-13 10:19
memberjenia.ivlev9-Mar-13 10:19 
AnswerRe: at runtime, change the displayed day to say march 20 Pin
Pyloz22-Mar-13 12:52
memberPyloz22-Mar-13 12:52 
QuestionMe gusto mucho Pin
victor manuel de anda5-Mar-13 11:35
membervictor manuel de anda5-Mar-13 11:35 
QuestionUpdated Code or VB & printing Pin
David DeLucia4-Mar-13 9:02
memberDavid DeLucia4-Mar-13 9:02 
AnswerRe: Updated Code or VB & printing Pin
Member 992793024-Mar-13 9:37
memberMember 992793024-Mar-13 9:37 
QuestionPrinting function that works Pin
jyuzakumo14-Feb-13 21:39
memberjyuzakumo14-Feb-13 21:39 
Questiondrop event Pin
Member 88503346-Feb-13 2:27
memberMember 88503346-Feb-13 2:27 
Questionday header not shrinking upon item deletion Pin
jenia.ivlev3-Feb-13 12:26
memberjenia.ivlev3-Feb-13 12:26 
Questioncan this be used in (vb) application Pin
Vijayakommi31-Jan-13 5:32
memberVijayakommi31-Jan-13 5:32 version Pin
Christoffer Svensson30-Jan-13 5:49
memberChristoffer Svensson30-Jan-13 5:49 
Questiononly three days appear. how make show 5 or 7 days. Pin
jenia.ivlev29-Jan-13 14:56
memberjenia.ivlev29-Jan-13 14:56 
AnswerRe: only three days appear. how make show 5 or 7 days. Pin
pianocomposer19-May-14 7:51
memberpianocomposer19-May-14 7:51 
Questionhow to use this code in my project? Pin
jenia.ivlev26-Jan-13 17:43
memberjenia.ivlev26-Jan-13 17:43 
AnswerRe: how to use this code in my project? Pin
jenia.ivlev29-Jan-13 14:55
memberjenia.ivlev29-Jan-13 14:55 
QuestionCan Convert to Hejri-Shamsi? Pin
Viper201026-Jan-13 14:44
memberViper201026-Jan-13 14:44 
QuestionBug. Item dis-appears at days before ViewStart , or After ViewEnd Pin
Member 22817711-Jan-13 12:10
memberMember 22817711-Jan-13 12:10 
AnswerRe: Bug. Item dis-appears at days before ViewStart , or After ViewEnd Pin
Member 22817712-Jan-13 9:10
memberMember 22817712-Jan-13 9:10 
QuestionError UserControl types Pin
MadsonLima14-Dec-12 9:22
memberMadsonLima14-Dec-12 9:22 
AnswerRe: Error UserControl types Pin
Verbiesteti1-Apr-13 22:57
memberVerbiesteti1-Apr-13 22:57 
QuestionWPF Version Pin
ram_1976-Dec-12 4:06
memberram_1976-Dec-12 4:06 
QuestionShows Appointment Count in monthview Pin
udan29-Nov-12 17:13
memberudan29-Nov-12 17:13 
AnswerRe: Shows Appointment Count in monthview Pin
helloah29-Nov-12 17:22
memberhelloah29-Nov-12 17:22 
QuestionAdd Columns to calendar tool Pin
rose lindo28-Nov-12 23:18
memberrose lindo28-Nov-12 23:18 
QuestionHow to add item to your calender Pin
benson ndirangu28-Nov-12 20:32
memberbenson ndirangu28-Nov-12 20:32 
AnswerRe: How to add item to your calender Pin
Pyloz22-Mar-13 12:54
memberPyloz22-Mar-13 12:54 

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.161205.3 | Last Updated 27 Aug 2009
Article Copyright 2009 by Jose Menendez Póo
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid