session 2 bai 2 ve winform

21
Session 2 Trình bày : Võ Ngọc Đạt Email : [email protected] Điện thoại : 0934.969.680 Slide 1 of 21 06/14/22 Grouping and Graphic Controls

Upload: mrtom16071980

Post on 13-Jun-2015

142 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Session 2 Bai 2 ve winform

Session 2

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

Slide 1 of 21

04/13/23

Grouping and Graphic Controls

Page 2: Session 2 Bai 2 ve winform

Slide 2 of 26

04/13/23

Module Introduction

Windows Forms contains various controls, which you can use to create a graphical user interface (GUI) of an application. One such category is values setting controls, which allow you to select the required values from a list of values. Another category is of the grouping controls, which enable you to organize the related controls in a group. Lastly, the other category is of the graphic controls, which are used to display images on the Windows Forms.

Page 3: Session 2 Bai 2 ve winform

Slide 3 of 38

04/13/23

Value Setting Controls Value setting controls are controls that allow you to select the desired values from a list of values. There are three types of value setting controls.

+ RadioButton+ CheckBox+ CheckedListBox

Page 4: Session 2 Bai 2 ve winform

Slide 4 of 38

04/13/23

"RadioButton" ControlThe RadioButton control allows the user to select a single value from the given set of values.

Page 5: Session 2 Bai 2 ve winform

Slide 5 of 38

04/13/23

Property Description

Appearance Specifies or retrieves a value indicating the appearance of the control. The radio button can appear as a normal button or as a Windows button.

AutoCheck Specifies or retrieves a value indicating whether the value of the Checked property and the appearance of the control change automatically when the control is clicked.

Checked Specifies or retrieves a value indicating whether the control is checked or not.

Image Specifies or retrieves the image appearing on the control.

Method Description

PerformClick Generates a Click event for the control,imitating the click action by the user.

Select Activates the control.

Event Description

CheckedChanged Occurs when there is a change in the value of the Checked property.

Click Occurs when the radio button control is clicked.

Page 6: Session 2 Bai 2 ve winform

Slide 6 of 38

04/13/23

Page 7: Session 2 Bai 2 ve winform

Slide 7 of 38

04/13/23

"CheckBox" Control The CheckBox control allows you to accept multiple values from a list of values. This control can be used when you want the user to choose one or more options.

Page 8: Session 2 Bai 2 ve winform

Slide 8 of 38

04/13/23

Property Description

Checked Specifies or retrieves a value indicating whether the control is checked.

CheckState Specifies or retrieves the state of the control. The control has three states Checked, Indeterminate, andUnchecked.

ThreeState Specifies or retrieves a value indicating whether the control will allow three checkstates instead of two.

Method Description

Select Activates the control.

Show Exhibits the control to the user.

Event Description

CheckedChanged Occurs when the Checked property of the control is changed.

CheckStateChanged Occurs when the CheckState property of the control is changed.

Click Occurs when the control is clicked.

Page 9: Session 2 Bai 2 ve winform

Slide 9 of 38

04/13/23

Page 10: Session 2 Bai 2 ve winform

Slide 10 of 38

04/13/23

"CheckedListBox" Control The CheckedListBox control is a control that allows you to accept multiple values from a list. This control is similar to a ListBox control, but it displays each value in a list along with a check box, which can be checked or unchecked.

Page 11: Session 2 Bai 2 ve winform

Slide 11 of 38

04/13/23

Property Description

CheckedIndices Indicates the collection of checked indexes in the control.

CheckedItems Indicates the collection of checked items in the control.

CheckOnClick Specifies or retrieves a value whether an item in the control should be ticked when clicked.

Items Retrieves the collection of all the items in the control.

SelectedIndex Specifies or retrieves the zero-based index of the currently selected item in the control.

SelectedItem Specifies or retrieves the currently selected item in the control.

SelectedItems Retrieves the collection of the currently selected items in the control.

Method Description

ClearSelected Unselects the items in the control.

GetItemChecked Retrieves a value, which indicates whether the specified item is checked.

GetItemText Retrieves the text of the specified item.

Event Description

ItemCheck Occurs when the checked state of an item changes.

SelectedlndexChanged Occurs when the Selectedlndex property of the control changes.

SelectedValueChanged Occurs when the SelectedValue property of the control changes.

Page 12: Session 2 Bai 2 ve winform

Slide 12 of 38

04/13/23

Page 13: Session 2 Bai 2 ve winform

Slide 13 of 38

04/13/23

Grouping Controls Grouping controls are controls that function as a container for other controls. They allow you to logically organize controls in a group.

The common types of grouping controls are:+ Panel+ GroupBox

Page 14: Session 2 Bai 2 ve winform

Slide 14 of 38

04/13/23

Graphic Controls Graphic controls are the controls that are used to display graphics on a form. The types of graphic controls commonly used are:

+ PictureBox

+ ImageList

Page 15: Session 2 Bai 2 ve winform

Slide 15 of 38

04/13/23

"PictureBox" Control A PictureBox control is used to display images on a form. You can display images as bitmap, GIF, JPEG,or icon file format using this control.

A PictureBox control can be a container that can hold only a single image at a time.

Page 16: Session 2 Bai 2 ve winform

Slide 16 of 38

04/13/23

Property Description

Image Specifies or retrieves the image displayed by the control.

ErrorImage Specifies or retrieves the image to be displayed in the control, if an error has occurred while the image is being loaded or the loading process has been cancelled.

SizeMode Specifies how the image is displayed in the control. The values for this property are defined in the PictureBoxSizeMode enumeration, which are:AutoSize: Fits the control automatically to the size of the image.CenterImage: Displays the image in the center of the control, if the control's size is larger than the image. Strechlmage: Stretches the image to fit within the size of the control.

Method Description

Load Loads a graphic in the control.

Page 17: Session 2 Bai 2 ve winform

Slide 17 of 38

04/13/23

"ImageList" Component

The ImageList component in Windows Forms is used to store a collection of images. The images stored in this component are displayed by other controls.

Page 18: Session 2 Bai 2 ve winform

Slide 18 of 38

04/13/23

Property Description

ColorDepth Specifies or retrieves the depth of the color of the image list.

Images Retrieves the ImageList. ImageCollection, which is acollection of the image objects in the existing control.

Imagesize Specifies or retrieves the size of the images in the image list.

Name Specifies or retrieves the name of the ImageList control.

Method Description

Draw Draws the image.

Event Description

RecreateHandle Occurs when the handle is recreated when the depth value of the image color changes.

Page 19: Session 2 Bai 2 ve winform

Slide 19 of 38

04/13/23

"SplitContainer" Control The SplitContainer control allows you to create complex user interfaces by dividing the form into two resizable panels, either horizontally or vertically.

The two panels are separated by a movable bar called as the splitter bar.

The SplitContainer control is used when you want to display the hierarchical information in one panel and its sub-contents in another panel.

Page 20: Session 2 Bai 2 ve winform

Slide 20 of 38

04/13/23Property Description

BorderStyle Specifies or retrieves the border style of the control using the BorderStyle enumeration.

FixedPanel Specifies or retrieves which panel of the control will not change in size when the container is resized.

IsSplitterFixed Specifies or retrieves a value indicating whether the splitter present on the control is fixed or movable.

Panell Retrieves the left or top panel of the control depending on the vertical or horizontal orientation.

Panel2 Retrieves the right or bottom panel of the control depending on the vertical or horizontal orientation.

Orientation Specifies or retrieves a value, which indicates the horizontal or vertical orientation of the panels.

Method Description

On SplitterMoved Triggers the SplitterMoved event.

Event Description

SplitterMoved Occurs when the splitter is moved.

Page 21: Session 2 Bai 2 ve winform

Slide 21 of 38

04/13/23