Home

Characteristics of a Month Calendar Control

 
 

Introduction

The calendar control is a rectangular object without a border. After placing it on the form, it displays the current month and only one month. This is because, by default, its width and height are set enough to accommodate only one month.

The Background Color of the Title Bar

To make it a highly visual object, a calendar control uses different colors to represent the background, week days, the background of the title bar, the text of the title bar, the text of the days of the previous month, and the text of the days of the next month.

As mentioned already, the top section of the calendar control displays buttons and labels. By default, these are positioned on top of a blue background. The background color of this section is controlled by the TitleBackColor property Calendar

The Font Color of the Title Bar

Calendar By default, the labels on the title bar display in a white color defined by the ActiveCaptionText system color. The color used to paint the text of the labels of the title bar is controlled by the TitleForeColor property

The Minimum and Maximum Dates

As mentioned already, to change month and subsequently the year of the calendar, the user can click the buttons continuously. By default, the user can navigate from 1/1/1753 to 12/31/9998. If you want to limit the allowable dates beyond which the user should not navigate, use the MinDate and the MaxDate properties. 

The First Day of the Week

Under the title bar, the short names weekdays display, using the format set in Control Panel. In US English, the first day is usually Sunday. If you want to start with a different day, set the value using the FirstDayOfWeek property. The names of weekdays use the same color as the TitleBackColor property. Under the names of the week, there is a horizontal line used as the separator. By default, this line separator is painted in black but it uses the same color as the numeric values of the days of the selected month.

The Background Color of the Calendar

Under the line separator, the numeric days of the month are listed. By default, the numeric days of the control display above a white background which is the Window system color. This color is controlled by the overridden BackColor property.

Calendar

The Font Color of the Days of the Current Month

Calendar The numbers of the days of the month display in two colors. The real days of the selected month display, by default, in a black color as the WindowText system color. The color of these days is controlled by the overridden ForeColor property.

The Font Color of the Days of the Trailing Months

Besides the days of the currently selected month, the calendar control also displays one or more days of the previous month and one or more days of the subsequent month. These are referred to as trailing months or trailing days. These are dayts that don't belong to the currently selected month. These days display in a different color controlled by the TrailingForeColor property. By default, this color is set to GrayText:

Calendar

Of course, you can programmatically change these colors. Although any color is allowed in any category, you should make sure that the calendar is still reasonably appealing and usable.

Practical LearningPractical Learning: Coloring the Month Calendar Control

  1. On the form, click the calendar control
  2. In the Properties window, change the following values:
    BackColor: 255, 192, 128
    ForeColor: Maroon
    TitleBackColor: 192, 64, 0
    TitleForeColor: Yellow
    TrailingForeColor: 255, 255, 192
  3. Save the form

Showing Today

The calendar control is used to let the user know today's date in two ways. On the calendar, today's date is circled by an almost hand-drawn ellipse. In the bottom section of the calendar, today's date is also displayed as a sentence. If you want to display or hide the bottom label, set the ShowToday Boolean property accordingly. For example, to hide it, set this property to false. The presence or absence of this ellipse is controlled by the ShowTodayCircle Boolean property whose default value is True. If you set this property to False, today's would appear without the ellipse:

Calendar

When a new calendar control is added to an application, it assumes today's date. If you want to change this date, use the TodayDate property.

Practical LearningPractical Learning: Hiding Today

  1. On the form, click the calendar control and, in the Properties window, double-click ShowToday to set its value to False
  2. Execute the application to test it
     
    Payroll Processing
  3. Close the form and return to your programming environment

Bold Dates

To accentuate the importance of one or more days of a month, you can bold some days. To bold some days of the calendar, create an array that holds the days. To visually create the list of dates, on the form, click the calendar control. In the Properties window, click BoldDates and click the ellipsis of its field. This would open the DateTime Collection Editor. To add a date member, you can click Add. On the right side, there would be a field named Date. You can type the date or you can click the arrow of the field. This would display a calendar:

DateTime Collection Editor

You can then select a date. In the same way, to complete the array, you can create the other dates you want. After creating the list, you can click OK.

To programmatically create the list of dates, create an array of DateTime values (each member of the array must be a recognizable DateTime value). Once the array is ready, assign it to the BoldDates property.

If you prefer the months bolded, assign the array to the MonthlyBoldedDates property.

 

Previous Copyright © 2007 FunctionX, Inc. Home