CHAPTER 2

advertisement
Chapter 2
More Controls
I.
Introducing More Controls
A.
B.
C.
D.
E.
F.
G.
H.
I.
II.
Each class of controls has its own set of properties – pg. 52
Text Boxes
 Review Question 1
1.
Text boxes are used primarily for user input. The Text
property holds the value input by the user. You can also assign
a literal to the text property during run time.
2.
Can change the properties at design time or in the code – pg. 53
Frames
1.
Frames are used as containers for other controls and to group
like items on a form to make forms easier to understand.
Check Boxes
1.
Allow the user to select an option – any number may be
selected – value property – 0 if unchecked 1 if checked, and 2
if grayed out or disabled.
Option Buttons
 Review Questios 2, 3
1.
Check boxes and option buttons allow the user to make
choices. In a group of option buttons, only one can be selected;
but in a group of check boxes, any number of the boxes may be
selected. The best way is to create a frame and then create each
option inside the frame, not on the form. The value of an
option button is true if selected and false if unselected.
Images
 Review Question 4
1.
Image controls hold a graphic-type file, which is assigned to
the Picture property. – pg. 55
Setting a Border and style
1.
The Appearance property of many controls can be set to 0 –
Flat, or 1 - 3D, which determines whether the control appears
flat or three-dimensional. – pg. 56
The Shape Control – enhance readablity of a screen or make more
entertaining – pg. 57
The Line Control – draw a line – ie. To divide the screen.
Working with Multiple Controls
A.
Selecting Multiple Controls at a time  Review Question 5
More Controls
1
1.
B.
C.
D.
E.
III.
You can select multiple controls and treat them as a group,
including setting common properties at once, moving them, or
aligning them.
a)
Drag a selection box around, or use the shift or control
keys – pg. 58
Deselecting a Group of Controls – click anywhere
Moving Controls as a Group – drag – pg. 59
Setting Properties for Multiple Controls – properties window is
shared by all of the selected controls
Aligning Controls – align submenu – pg. 59
1.
Horizontal spacing – spacing between controls
2.
Vertical spacing – change the vertical alignment of multiple
selected controls
3.
Twips - - pg. 61
Designing Your Applications for User Convenience – clear and consistent
1.
B.
C.
D.
E.
2
Make your programs easier to use by following Windows
standard guidelines for colors, control size and placement,
access keys, default and cancel buttons, and tab order.
Designing the User Interface
1.
Understandable and comfortable for the user – like other
Windows applications
Defining Keyboard Access Keys
 Review Question 6
1.
Define keyboard access keys by including an ampersand in the
caption of command buttons, option buttons, and check boxes.
– pg. 62, bottom
Setting the Default and Cancel Properties of Command Buttons
 Review Question 7
1.
Set the Default property of one command button to True, so
that the user can press Enter to select the button. If you set the
Cancel property to True, the button will be selected when the
user presses the Esc key. – pg. 62
Setting the Tab Order for Controls
 Review Questions 9, 10
1.
The focus moves from control to control as the user presses the
Tab key. The sequence for tabbing is determined by the
TabIndex properties of the controls.
a)
Tabstop property – set to true – capable of receiving
focus
Chapter 2
Tabindex property – order of thefocus – lowest is 0 –
increase by 1 – pg. 64 – is part of the tab sequence, but
not able to receive focus.
Setting the Form’s Location on the Screen – form layout window, or
setting the screen position in the startup position property of the form.
Creating ToolTips
 Review Question 8
1.
Set the ToolTipText property of a control to make a ToolTip
appear when the user pauses the mouse pointer over the
control. – pg. 66
b)
F.
G.
IV.
Coding for the Controls – changes in properties are done as part of the code
when the project executes
A.
Clearing Text Boxes and Labels
 Review Question 12
1.
Clear the Text property of a text box or the Caption property of
a label by setting it to an empty string. – pg. 66
B.
Resetting the Focus
Review Question 11
1.
To place the insertion point into a text box as the program is
running, use the SetFocus method. – pg. 66
C.
Setting the Value Property of Option Buttons and Check Boxes – help
the user when making selections
1.
Option button selected initially – value property to true
2.
Check box – 0 = unchecked, 1 = checked, 2 = grayed – pg. 67
D.
Changing the Font Properties of Controls  Review Question 13
1.
To change font attributes of a text box or a label, use the Font
property of the control. The Font property refers to a Font
object, with properties for bold, italic, underline, size, etc. – pg.
68
E.
Changing the Color of Text
1.
Change the color of text in a control by changing the ForeColor
property.
2.
You can use the Visual Basic color constants to change colors
during run time. – pg. 68
F.
Changing Multiple Properties of a Control  Review Question 14
1.
The With and End With statements provide an easy way to
refer to an object multiple times without repeating the object’s
name. – pg. 69 – indent for readability – more efficient and run
faster
G.
Concatenating Text
 Review Question 15
1.
Joining two strings of text is called concatenation and is
accomplished by placing an ampersand between the two
More Controls
3
H.
I.
4
elements. (A space must precede and follow the ampersand.) –
pg. 69
Continuing Long Program Lines
 Review Question 16
1.
Use a space and an underscore to continue a long statement on
another line – line continuation character – pg. 70
Using the Default Property of a Control
 Review Question 17
1.
Using the default property of a control allows you to refer to an
object without naming the property.
Chapter 2
Download