1. Trang chủ
  2. » Giáo án - Bài giảng

Chapter 2 More controls

32 180 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề More Controls in C Programming
Trường học University of Example
Chuyên ngành Programming
Thể loại Lecture notes
Năm xuất bản 2009
Thành phố Hanoi
Định dạng
Số trang 32
Dung lượng 856,5 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Group Box grp• Used as containers for other controls such as radio buttons and check – What is displayed on the top edge of the group box Group Group... Check Box chk• Used for user in

Trang 1

Chapter 2

More Controls

Programming In

C Shap

Trang 2

Controls in the Toolbox

Trang 5

3 Text Box (txt)

• Used for user input/data entry

– What is displayed in text box

– What user entered in text box

Trang 6

4 Group Box (grp)

• Used as containers for

other controls such as

radio buttons and check

– What is displayed on the

top edge of the group box Group Group

Trang 7

5 Check Box (chk)

• Used for user input/data entry

• Allows the user to select or

deselect 1 or more in any group

Checked Property (stores current

state of the Check Box)

– Checked = True

– Unchecked = False

• CheckChanged Event

– Occurs when user clicks on one of

the Check Boxes

Check box

Trang 8

6 Radio Button (rad)

• Used for user input/data entry

Allows the user to select only 1 in any group

• First create a group and then create each

radio button inside the group

Checked Property (stores current state of

the Radio Button)

• Checked = True

– Unchecked = False

• CheckChanged Event

– Occurs when user clicks on one of the

Trang 9

7 Picture Box (pic)

– StretchImage causes graphic to

be resized to match the size of

the control

Trang 10

7 Form (frm) Đặc biệt chứa các

control khác

Common Properties Description

Enter is pressed.

Escape key is pressed.

none, single, dimensional).

Trang 11

three-7 Form (frm) Đặc biệt chứa các

control khác (cont)

Common Methods Description

Close() Closes a Form and releases all

resources, such as the memory used for the Form's controls and

components A closed Form cannot be reopened

Show() Displays a hidden Form

Hide() Hides a Form, but does not destroy the

Form or release its resources

Trang 12

7 Form (frm) Đặc biệt chứa các control khác (cont)

displayed in the Visual Studio editor when you double click the Form in the Visual Studio

designer.

Trang 13

Selecting Multiple Controls

• SHIFT-Click or CTRL-Click to

select/deselect multiple controls

• Use the mouse to drag a selection box

around multiple controls

• To deselect all selected controls click

elsewhere on the form

Trang 14

Selecting Multiple Controls

Start

here

Drag

to here

Trang 15

What Can be Done with

Multiple Selected Controls?

• Use Format Menu or Layout Toolbar to

– Align them to each other

• Move them as a group

• Set their common properties

Trang 16

Designing the User Interface

• To the user the Interface should be

– Sans Serif Fonts are best, not boldface or large

Trang 17

Keyboard Access Keys

• Also referred to as Hot Keys

• Underlined Letter

• User presses ALT + underlined letter

• Use Windows-Standard Keys

• Defined using Text Property

Text=&OK Text=E&xit

Trang 18

Default & Cancel Buttons

Responds to ESC key

Form's CancelButton Property

Trang 19

Focus

• Not all control types can receive the focus

• TabStop Property (applicable only for controls that are capable of receiving the focus- labels and pictures can’t)

– Designates whether a control is allowed to

receive the focus; True or False

Trang 20

Tab Order

focus through a form in an organized manner; top

to bottom, left to right

• TabStop property (yes is the defaualt)

– Number in tab sequence

– 0 for first control to receive the focus when the form

loads

Trang 21

Setting TabIndex Property

• View menu, TabOrder

• Click on each control in sequence to set

TabIndex property of controls automatically

Trang 22

Form's Screen Location

Trang 23

• Small label that is displayed when user places

pointer on a control and pauses

• Usually used with Command Buttons

• Steps for creating ToolTips

– Add a ToolTip Control to Form

• Appears in the Component Tray, pane at bottom of Form

Designer where nondisplay controls are shown

– Set ToolTip on ToolTip1 Property of each control to

the text of tip

Trang 25

txtName.Text = ""

lblMessage.Text = ""

txtCourse.Clear( )

Clearing Text Boxes & Labels

– Empty String is 2 quotation marks with no space

between them ("")

Trang 26

txtName.Focus( )

Resetting the Focus

• Places the Insertion Point in a Text Box

• Use the Focus Method

Trang 27

radRed.Checked = True chkBold.Checked = False

Checked Property of Check Boxes and Radio Buttons

• Selects/Deselects Check Box or Radio

Button

• Set Checked Property

Trang 28

C# Color Constants

Class

keyword Color followed by a period

txtName.ForeColor = Color.AliceBlue lblMessage.BackColor = Color.White

Trang 29

lblFullName.Text = txtFName.Text + " " & txtLName.Text lblNote.Text = "Today's w eather is " + txtWeather.Text & "."

Concatenation

• Think of it as "glueing" text strings together

• Example: txtFName contains First Name

txtLName contains Last Name

Trang 30

private void radgreen_CheckedChanged(object sender, EventArgs e)

{ lblDDang.ForeColor = Color.Green; }

Trang 31

Ví Dụ 2 LightSwitcher

picMo picTat

lblhuongdan

Ngày đăng: 13/05/2014, 11:40

TỪ KHÓA LIÊN QUAN