Recipe 7.20. Creating a Calendar


Problem

You want to display a full-year calendar on a reasonably sized form.

Solution

Use the MonthCalendar control, dock it to fill its parent form, and size the form large enough that all 12 months appear.

Discussion

The MonthCalendar control normally displays only one month at a time, with buttons and controls to toggle through neighboring months and years as desired. However, if it's docked to the center of the form ("Fill") or other parent control, it attempts to fill the area completely. Instead of displaying larger text, the control displays multiple months either side by side or stacked vertically, depending on which way you stretch the form. Stretch the form a little, and suddenly the one-month calendar changes to display two months. Keep going, and it will display three, four, or more months in a rectangular array. At a form size of about 551 pixels wide by 615 pixels high, a full year of a dozen months displays nicely in a three-across and four-high pattern. Figure 7-21 shows the form at this size.

Figure 7-21. A nice one-year calendar displayed with no code at all





Visual Basic 2005 Cookbook(c) Solutions for VB 2005 Programmers
Visual Basic 2005 Cookbook: Solutions for VB 2005 Programmers (Cookbooks (OReilly))
ISBN: 0596101775
EAN: 2147483647
Year: 2006
Pages: 400

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net