Continue from The MonthCalendar Class

The MonthCalendar Class
The MonthCalendar class represents a control that displays days of a month. A MonthCalendar control is shown in Figure 18. By default, when first displayed, the control displays the current month on the user's computer system. Users can select a day by clicking on it or select a range of dates by holding the Shift key while clicking the date at the end of the desired range. Users can also scroll backward and forward to previous or upcoming months, or they can click on the month part and more quickly select one of the 12 months. To change the year, users can click on the year part and click the scrollbar that appears.


Figure 18
Two properties determine the date range that users can select: MinDate and MaxDate. The MinDate property is a DateTime value representing the minimum date permitted; its default is January 1, 1753. The MaxDate property determines the maximum date allowed. By default, the value of MaxDate is December 31, 9998.
If you want your MonthCalendar to display a certain range of dates, you need to change these two properties. For instance, the following code allows the user to select a date between January 1, 1980 and December 14, 2010:
CODES:
The MonthCalendar class has a TodayDate property that represents today's date. The user selecting a new date does not automatically change the value of TodayDate. If you want the date selected by the user to be reflected as today's date, you can use the Date_Changed event handler to change its value explicitly, as shown in the following code:
CODES:
A DateRangeEventArgs object is passed as an argument to the DateChanged event handler. Its members include a Start property, which represents the beginning of the range of selected dates, and an End property, which represents the end of the range of selected dates. The previous code simply assigns the value of the Start property to TodayDate. Later, if you need to know the value of the userselected date, you can query the TodayDate property.
Note that the MonthCalendar control has a fixed size. It will ignore any attempt to change its Size property. If you need more flexibility in terms of the space it occupies, use a DateTimePicker control.


The PictureBox Class
The PictureBox class represents a control to display an image. Loading an image into this control is achieved by assigning a System.Drawing.Bitmap object to its Image property, as the following code does:
CODES:
In addition, the PictureBox class has the BorderStyle and SizeMode properties. The BorderStyle property determines the PictureBox object's border and can take as its value any member of the BorderStyle enumeration: None (the default value), FixedSingle, and Fixed3D.
The SizeMode property determines how the image assigned to the Image property is displayed. The SizeMode property can take any of the members of the PictureBoxSizeMode enumeration: AutoSize, CenterImage, Normal (the default value), and StretchImage.

The RadioButton Class
The RadioButton class represents a radio button. When you add more than one radio button to a form, those radio buttons automatically become one group, and you can select only one button at a time. If you want to have multiple groups of radio buttons on a form, you need to use a GroupBox or Panel control to add radio buttons in the same group to a single GroupBox or Panel.
The following code shows how you can add two radio buttons to a GroupBox and then add the GroupBox to a form. Notice that you don't need to add each individual radio button to a form:
CODES:
Like a checkbox, the appearance of a radio button is determined by its Appearance property, which can take one of two members of the Appearance enumeration: Normal (the default) and Button. You don't normally use Appearance.Button because it will make your radio button look like a button. The CheckAlign property determines the text alignment of the radio button. Its value is one of the members of the ContentAlignment enumeration: BottomCenter, BottomLeft, BottomRight, MiddleCenter, MiddleLeft (the default), MiddleRight, TopCenter, TopLeft, and TopRight. The Checked property takes a Boolean. Setting this property to True selects the radio button (and deselects others in the group); setting it to False unselects it.

The TextBox Class
This class represents a text-box control, a control that can accept text as user input. Its major properties are:

Multiline
This property can be set to True (indicating that multiple lines are permitted) or False (single-line mode). By default, the value for this property is False.


AcceptsReturn
If True (its default value), and if the Multiline property is also True, pressing the Enter key will move to the next line in the text box. Otherwise, pressing Enter will have the same effect as clicking the form's default button.

CharacterCasing
This property determines how characters that are input by the user appear in the text box. It can take any member of the CharacterCasing enumeration: Normal (the default), Upper, and Lower. Setting this property to CharacterCasing.Upper translates all input characters to uppercase. Assigning CharacterCasing.Lower to this property converts all input to lowercase. CharacterCasing.Normal means that no conversion is performed on the input.

PasswordChar
This property defines a mask character to be displayed in place of each character input by the user, thereby turning the text box into a password box. This property applies only to a singleline text box (i.e., a text box whose Multiline property is False). It affects the display, but not the value of the Text property.

ScrollBars
In a multiline text box, this property determines whether scrollbars are shown on the control. The property can take any member of the ScrollBars enumeration: None (the default), Horizontal, Vertical, and Both.

TextAlign
This property determines how text is aligned in the text box. It can take any member of the HorizontalAlignment enumeration: Center, Left, and Right.

The Timer Class
The Timer class represents a timer that can trigger an event at a specified interval. At each interval, a Timer object raises its Tick event. You can write code in the Tick event handler that runs regularly. The Timer will raise its Tick event only after you call its Start method. To stop the timer, call its Stop method.

The interval for the Timer is set by assigning a value to its Interval property. It accepts a number representing the interval in milliseconds. The following code, which prints an incremented integer from 1 to 20 to the console, shows how to use a timer:
CODES:

No comments:

Post a Comment