Not long ago I came across some cool demos showing new features in Windows Forms 2.0. Some of these show how to emulate look and feel of some well know applications (like MS Outlook, Money, Quicken, File Explorer or MSN Messenger). In particular I found there an interesting example of customizing the DataGridView control to implement multi-view schedule component emulating the Outlook Calendar. This sample supports rendering calendar events in day, week and month view. I think it would be quite interesting for anyone who needs to implement some custom rendering or behavior in this control.
Recently it turned out I could find some use for a month schedule, so after tinkering with the sample for a while I was able to extend it to fulfill my needs. Below you can see how it turned out and what changes I’ve made.
- Added row headers with week numbers,
- Added fancy row and column headers,
- Enabled to select specific appointments with mouse and from code,
- Month name on first cell and first day of month,
- Different colors for current month and previous/next one.
Generally this was quite easy and fun to accomplish and really shows how well designed is the DataGridView control (especially when compared to old DataGrid). Of course it lacks many features that you can find in professional components like DevExpress XtraSchedule or Infragistics’ UltraWinSchedule, but I think it is sufficient in many simple cases.
Wow. I didn't expect my little sample will even interest single person. I already received more then 20 requests to send source code and I slowly loose track to whom I sent it or not. Therefore I decided to release it to ProjectDistributor for everyone. So if you still want to see how this was made please help yourself and get the source code.
There are two changes in this release:
- Added cell overflow indicators.
- Fixed rows autosizing.
I hope you enjoy it, and don't forget to let me know what you think of it.
Because the ProjectDistributor site is down I've moved the code to
SkyDrive MSDN Code Gallery:
Download the source code