Session 4 Bai 4 ve winform

13
Session 4 Trình bày : Võ Ngọc Đạt Email : [email protected] Điện thoại : 0934.969.680 Slide 1 of 13 06/18/22 Date Controls and Timer Component

Transcript of Session 4 Bai 4 ve winform

Page 1: Session 4 Bai 4 ve winform

Session 4

Trình bày : Võ Ngọc ĐạtEmail : [email protected]Điện thoại : 0934.969.680

Slide 1 of 13

04/13/23

Date Controls and Timer Component

Page 2: Session 4 Bai 4 ve winform

Slide 2 of 26

04/13/23

Module Introduction Date controls allow you to select the required date and time and validates the input to avoid any invalid values. The MonthCalendar control allows you to select multiple dates and to display multiple months at a time. The Timer component is similar to a stop watch that allows you to track the time for a particular task.

Page 3: Session 4 Bai 4 ve winform

Slide 3 of 38

04/13/23

Purpose Date and time controls are used to select or display date and time. These controls provide a calendar in a graphical format, which allows you to easily select a particular date. This helps in avoiding manual mistakes for date and time by restricting the user from entering any invalid date.There are two types of date controls. They are:

+ DateTimePicker

+ MonthCalendar

Page 4: Session 4 Bai 4 ve winform

Slide 4 of 38

04/13/23

"DateTimePicker" Control The DateTimePicker control allows you to select an item from a list of dates or times. It appears as a text box along with a drop-down calendar and displays the current date in a particular format. The calendar allows you to view the days of a week or browse through the months

Page 5: Session 4 Bai 4 ve winform

Slide 5 of 38

04/13/23Property Description

CustomFormat Specifies or retrieves the custom date or time format string.

Format Specifies or retrieves the format of date and time displayed in the control.

MinDate Specifies or retrieves the minimum date and time that you can select in the control.

MaxDate Specifies or retrieves the maximum date and time that you can select in the control.

ShowCheckBox Specifies or retrieves a value, which indicates whether the CheckBox control should appear at the left side of the date, which is selected.

Value Specifies or retrieves the date or time assigned to the control.

Method Description

Focus Sets the input focus on a DateTimePicker control.

Show Displays a DateTimePicker control on the form.

Event Description

FormatChanged Occurs when the value of the Format property is changed.

ValueChanged Occurs when the value of the Value property is changed.

Page 6: Session 4 Bai 4 ve winform

Slide 6 of 38

04/13/23

Page 7: Session 4 Bai 4 ve winform

Slide 7 of 38

04/13/23

Page 8: Session 4 Bai 4 ve winform

Slide 8 of 38

04/13/23

"MonthCalendar" Control The MonthCalendar control allows you to view and select a date with the help of a graphical calendar. The calendar appears as drop-down grid of rows and columns displaying the dates of a particular month.

The MonthCalendar control is similar to the DateTimePicker control, but allows you to select multiple dates simultaneously. Unlike the DateTimePicker control, the MonthCalendar control cannot display time and does not allow you to type dates.

Page 9: Session 4 Bai 4 ve winform

Slide 9 of 38

04/13/23

Property Description

CalendarDimensions Specifies or retrieves the total number of rows and columns of the months appearing in the calendar.

ShowToday Specifies or retrieves a value indicating whether the date value in the TodayDate property will appear at the bottom of the control.

ShowTodayCircle Specifies or retrieves a value, indicating whether today's date is circled.

ShowWeekNumbers Specifies or retrieves a value indicating whether a month calendar control displays the week numbers (1-52) to the left of each row of days.

TodayDate Specifies or retrieves a value that is used as the current date by the month calendar control.

Event Description

DateChanged Occurs when the selected date in the month calendar control is changed.

DateSelected Occurs when the user selects a date in the month calendar control using the mouse.

Method Description

AddAnnuallyBoldedDate Adds a day that is displayed in bold in the month calendar control on an annual basis.

AddBoldedDate Adds a day to be displayed in bold in the month calendar control.

AddMonthlyBoldedDate Adds a day that is displayed in bold in the month calendar control on a monthly basis.

Page 10: Session 4 Bai 4 ve winform

Slide 10 of 38

04/13/23

Page 11: Session 4 Bai 4 ve winform

Slide 11 of 38

04/13/23

Page 12: Session 4 Bai 4 ve winform

Slide 12 of 38

04/13/23

"Timer" Component

The Timer component is a component that generates an event at regular intervals. For example, you can use the component to set a time within which the user has to complete answering the required number of questions. When the specified time interval is over, you can perform certain tasks such as asking the user to stop answering the questions.

Page 13: Session 4 Bai 4 ve winform

Slide 13 of 13

04/13/23

Property Description

Enabled Specifies or retrieves a value indicating whether the timer is running.

Interval Specifies or retrieves the time in milliseconds between the timer ticks.

Method Description

Start Starts the timer.

Stop Stops the timer.

Event Description

Tick Occurs when a particular time interval is over and the Enabled property of the component is true.