Click here to Skip to main content
Click here to Skip to main content
Go to top

Calendar DayView Control

, 20 Jun 2006
Rate this:
Please Sign up or sign in to vote.
A calendar DayView control.


This article describes creating a day view control for visualizing schedule functions in required applications. I have cloned the Outlook day view appearance for similar use. Here is a screenshot:

Office 12 Theme:

Sample Image

Office XP Theme:

Sample Image


Before writing this control, I was in need of a day view control that just looks like that in Outlook. I have found some commercial toolkits but none of them meets my requirements. Some of those want that all appointments be given before showing the control, some of those are not open source, etc. So I wrote this control in a "hurry development", and I think other people can use it. Pay back time for using the CodeProject Smile | :)

What we have?

  • You can create your appointment class to hold special information (other than start, end dates and title).
  • You don't need to read all appointments from the DB or something like that.
  • You can specify how much days will be shown.
  • You can colorize appointments to show different views.
  • In-place editing.
  • Drag drop operations.
  • No Win32 API.
  • Theme based rendering.

By the way, it's compiled under the final release of .NET 2.0. If you don't have it, you need to recompile the project.

Using the code

This control uses a class named "Appointment" to visualize the view. The DayView control doesn't pay attention to saving appointments to the DB or fetching them. So, you need to write your own DB logic and answer the events.

The control implements these events to interact with the hosting application:

  • dayView1.NewAppointment
  • dayView1.ResolveAppointments
  • dayView1.SelectionChanged

The sample application uses a list collection as the container for appointments. You may use a cached DB source too.

NewAppointment event

This is raised when the user wants to create an appointment. Event arguments contain start date, end date, and title values of the new appointment. You can create your appointment class that inherits from the DayView.Appointment base class.

The sample application just creates a new appointment, and adds it to the list collection.

void dayView1_NewAppointment(object sender, NewAppointmentEventArgs args)
    Appointment m_Appointment = new Appointment();

    m_Appointment.StartDate = args.StartDate;
    m_Appointment.EndDate = args.EndDate;
    m_Appointment.Title = args.Title;


ResolveAppointments event

This event is raised when the DayView control needs to show an appointment on a date. Event arguments contain the start date and end date of the required range of dates.

The sample application scans the list collection for a specified date range. You can fetch them from your own DB too.

private void dayView1_ResolveAppointments(object sender, 
                      ResolveAppointmentsEventArgs args)
    List<Appointment> m_Apps = new List<Appointment>();

    foreach (Appointment m_App in m_Appointments)
        if ((m_App.StartDate >= args.StartDate) && 
            (m_App.StartDate <= args.EndDate))

    args.Appointments = m_Apps;

Selection Changed event

This event is raised when the user selects an appointment.

private void dayView1_SelectionChanged(object sender, EventArgs e)
    label3.Text = dayView1.SelectionStart.ToString() + 
                  ":" + dayView1.SelectionEnd.ToString();

The sample application shows the start date and the end date of the selected appointment in a label.

Points of interest

When I wrote this control, the hard part was sorting the appointments on screen without crossing over. The control internally uses an "AppointmentView" class to hold the state of appointments on screen. The rest of the code was drawing and isolating from the external application.

You may see some remarked codes about all-day events, but currently all-day events is not complete. When I finish it, I'll update this article. (Thanks to Claus Espersen for implementing the Office 12 theme and bug fixes.)


  • 14.07.2006
    • Bug fixes.
    • Start hour and start minute properties implemented.
    • Theme based rendering implemented.
    • AllowNew property implemented.
    • Mouse drag drop bugs fixed.
    • Internal changes for all day events.
    • Zoom feature implemented.
  • 11.09.2005
    • Initial release.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ertan Tike
Web Developer
Turkey Turkey
No Biography provided

Comments and Discussions

QuestionCalendar shows same appointments every month Pinmemberpazzokli21-Mar-14 3:41 
QuestionMerhaba PinmemberMember 1047238618-Dec-13 5:42 
QuestionColumn fixed - show minutes [modified] PinmemberMember 80596961-Oct-13 4:36 
QuestionAppointment change Pinmemberneo11on23-Aug-13 22:17 
Questionretrieving data on Dayview control from ms access database Pinmembernaivngupta18-Aug-13 11:30 
AnswerRe: retrieving data on Dayview control from ms access database Pinmemberneo11on23-Aug-13 22:14 
Questionday names in another language? PinmemberMohamed Medhat11-Aug-13 6:04 
Questioncompleted the task Pinmemberneo11on9-Aug-13 7:44 
GeneralNAO ENTENDO NADA C# Pinmemberh3nr1qu314-Jun-13 11:51 
GeneralRe: NAO ENTENDO NADA C# PinmemberOtter Banks10-Aug-13 4:03 
Questionexactly what i need Pinmemberilyaskahya24-Mar-13 22:24 
QuestionLatest source code Pinmemberamnontopel11-Dec-12 0:56 
GeneralMy vote of 4 PinmemberChelo19746-Sep-12 15:29 
QuestionVisual Basic for Visual Studio 2010 PinmemberPaulnz12-Sep-12 10:31 
Questionselecting bug Pinmembersomur-ruteeb14-Jun-12 14:35 
Questionproblem saving appointment Pinmemberremert698-Feb-12 21:05 
AnswerRe: problem saving appointment PinmemberFaiszsal28-Jul-13 1:18 
GeneralRe: problem saving appointment Pinmemberpazzokli21-Mar-14 3:42 
GeneralRe: problem saving appointment PinmemberFaiszsal21-Mar-14 7:16 
QuestionDelete NewAppointment? PinmemberPato de Borracfha23-Oct-11 1:57 
QuestionWeb control PinmemberPrincVenu10-Oct-11 22:21 
QuestionNice One PinmemberSaqlain Raza7-Oct-11 4:41 
GeneralMy vote of 3 Pinmemberbuyong26-Sep-11 20:34 
NewsAppointmentID is back Pinmembernt238229-Aug-11 8:10 
QuestionRe: AppointmentID is back Pinmembermarcopuccio2-Jan-13 23:38 
NewsMark more then one day in the calender Pinmembernt238229-Aug-11 8:02 
NewsGrip on a wrong position [modified] Pinmembernt238227-Aug-11 2:06 
BugI have a small bug PinmemberWilltwinny28-Jul-11 12:57 
QuestionUsing With Database PinmemberMehmet Yılmaz Yılmaz14-Jul-11 5:52 
GeneralPopulating the control PinmemberMember 79015268-May-11 23:32 
Generaldatebase problem i need help Pinmemberosman osmanssson8-May-11 7:35 
GeneralProblem: X displayed PinmemberCucca7728-Apr-11 8:00 
GeneralFont, BackColor, Padding PinmemberKonrad8420-Apr-11 0:09 
GeneralAll Day Events PinmemberNicoel18-Apr-11 9:26 
QuestionAmazing work... PinmemberDavidSavage9-Mar-11 11:55 
GeneralLatest version Pinmemberalgreat25-Jan-11 0:49 
GeneralRe: Latest version Pinmemberkiloolik120-Mar-11 7:30 
GeneralBig problem with appointment rendering Pinmemberlbarciko16-Dec-10 20:36 
GeneralAbsolutely brilliant PinmemberVidhu Jain2-Dec-10 5:01 
QuestionHow to test Appointment exist Pinmemberhoangsamac12-Oct-10 0:38 
QuestionHow to test Appointment exist ? please help me. Pinmemberhoangsamac12-Oct-10 0:37 
GeneralMy vote of 5 PinmemberLance.Zhang18-Aug-10 20:51 
GeneralNeed Printing help Pinmembermindserve16-Aug-10 0:34 
GeneralPrinting Pinmembermindserve5-Aug-10 1:31 
Generalquestion about appointments PinmemberN.Sham4-Jul-10 2:32 
GeneralRe: question about appointments PinmemberMember 53816805-Sep-10 5:11 
GeneralNewAppointment and ResolveAppointments Errors PinmemberNinjadan920-Jun-10 8:14 
GeneralDeleting an appointment PinmemberN.Sham9-May-10 20:10 
GeneralRe: Deleting an appointment PinmemberOllipolli10-May-10 7:48 
QuestionGreat, but has anybody this in WPF? Pinmemberramzess4-May-10 7:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web04 | 2.8.140922.1 | Last Updated 20 Jun 2006
Article Copyright 2005 by Ertan Tike
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid