Presentation is loading. Please wait.

Presentation is loading. Please wait.

Brief description on how to navigate within this presentation (ppt)

Similar presentations


Presentation on theme: "Brief description on how to navigate within this presentation (ppt)"— Presentation transcript:

1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf
Brief description on how to navigate within this presentation (ppt) The first time a Key Term from the chapter is used in the ppt it will display in blue Gold colored text boxes display coding examples Slides will be numbered (# of #) when multiple slides on same topic (Slide title) Speaker notes are included where appropriate for slides (*)Denotes either a comment for page reference to textbook or slide reference in ppt

2 2 User Interface Design Chapter McGraw-Hill
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.

3 Objectives (1 of 2) Use text boxes, group boxes, check boxes, radio button, and picture boxes effectively Set the BorderStyle property to make controls appear flat or three-dimensional Select multiple controls and move them, align them, and set common properties Make your projects easy for the user to understand and operate by defining access keys, setting an accept and a cancel button, controlling the tab sequence, resetting the focus during program execution, and causing ToolTips to appear

4 Objectives (2 of 2) Clear the contents of text boxes and labels.
Change text color during program execution. Code multiple statements for one control using the With and End With statements. Concatenate (join) strings of text. Make a control visible or invisible at run time by setting its Visible property.

5 More Controls Click the plus and minus signs on the tabs to open and close each section Forms can have several different types of controls such as text boxes, group boxes, check boxes, radio buttons, picture boxes Each class of controls has its own set of properties. To see a complete list of the properties for any class of control, you can (1) place a control on a form and examine the properties list or (2) click on a tool or a control and press F1 for context-sensitive Help.

6 Text Box Allows for user input Text property
What is displayed in text box What user entered in text box TextAlign property or HorizontalAlignment.Left Controls alignment of text in the text box Use a text box control when you want the user to type some input and a form may have more than one textbox The user can move from one box to the next, make corrections, cut and paste if desired, and click the Display button when finished You can set the properties of textboxes or you can use code to set values for the property 7

7 Masked Text Box A specialized form of the Text Box
You can specify the format (the Mask property) of the data required of the user For example, you can select a mask for a ZIP code, a date, a phone number, or a social security number At run time the user cannot enter characters that do not conform to the mask

8 Group Box Used as containers for other controls such as radio buttons and check boxes Improves readability of form by separating the controls into logical groups Example Names for Group Boxes colorGroupBox styleGroupBox 7

9 Check Box Allows the user to select or deselect one or more items in any group Checked property Checked = True Unchecked = False Use the Text property for the text you want to appear next to the box Example names for Check Boxes boldCheckBox italicCheckBox 10

10 Radio Button User may select only one in any group
First create a group box and then create each radio button inside the group box Checked property Selected = True Unselected = False Text property What is displayed next to the radio button Example Names for Radio Buttons redRadioButton blueRadioButton 9

11 Picture Box Displays/contains an image Image property
Complete path and filename of graphic; it’s a good idea to place the graphic into the folder with your project before it is assigned to a picture box Can set extension to .bmp, .gif, .jpg, .jpeg, .png, .ico, .emf, .wmf PictureBox controls have several useful properties such as the SizeMode property StretchImage causes picture to be resized to match the size of the control or the Visible property which can be set to False to make the picture disappear 11

12 Borders and Styles Most controls can appear to be three-dimensional or flat Labels, text boxes, and pictures boxes all have a BorderStyle property with different style choices including: None FixedSingle Fixed3D properties can be changed to the style of choosing Fixed3D – default for text boxes None – default for labels and picture boxes 14

13 Selecting Multiple Controls
(1of 2) There are several methods of selecting multiple controls which means controls can be moved as a group Shift-Click or Ctrl-Click to select/deselect multiple controls Use the mouse to drag a selection box around multiple controls When wanting to select most of the controls on the form used a combination of the two methods To deselect all selected controls click elsewhere on the form 15

14 Selecting Multiple Controls (2 of 2)
Use the mouse to drag a selection box around multiple controls When multiple controls are selected, each has resizing handles (if resizable)

15 Working with Multiple Controls
What are some of the benefits of working with Multiple Controls? Drag a group of selected controls to move the entire group to a new location at one time Set common properties Use Format Menu or Layout Toolbar to Align controls to each other Make controls the same size Modify the spacing between controls

16 Designing the User Interface
The design of the screen should be easy to understand and “comfortable” for the user. The best way to accomplish these goals is to follow industry standards for the color, size, and placement of controls. To the user the Interface should be Familiar Comfortable Organized – group controls Sans Serif Fonts are best, not boldface or large Gray is a neutral color that works well Keyboard Accessible One of the goals of good programming is to create programs that are easy to use. Your user interface should be clear and consistent You should design your applications to match other Windows applications.

17 Keyboard Access Keys Many people prefer to use the keyboard, rather than a mouse, for most operations Also referred to as Hot Keys Underlined Letter User presses Alt + underlined letter Use Windows-Standard Keys Defined using Text property You can set access keys for buttons, radio buttons, and check boxes Text=&OK Text=E&xit 17

18 Accept & Cancel Buttons
Accept Button Identified visually on Form by its darker outline Responds to Enter key Form's AcceptButton property Cancel Button Form's CancelButton property An example of a Cancel button is the Esc key Once a person’s fingers are on the keyboard, most people prefer to press the Enter key, rather than to click the mouse. If one of the buttons on the form is the accept button, pressing Enter is the same as clicking the button. An example of a good time to set the CancelButton property is on a form with OK and Cancel buttons.

19 Setting the Tab Order for Controls (1 of 2)
One control on a Form always has the focus Not all control types can receive the focus Text boxes, buttons - focus Picture boxes and labels – no focus TabStop property is applicable only for controls that are capable of receiving the focus Designates whether a control is allowed to receive the focus; set to True or False TabIndex property determines the order the focus moves as the Tab key is pressed You can see the focus change as you tab from control to control. For controls such as buttons, the focus appears as a thick blue border. For text boxes, the insertion point (also called the cursor) appears inside the box. Two properties determine whether the focus stops on a control and the order in which the focus moves. Controls that are capable of receiving focus have a TabStop property, which you can set to True or False. If you do not want the focus to stop on a control when the user presses the Tab key, set the TabStop property to False. The TabIndex property determines the order the focus moves as the Tab key is pressed. As you create controls on your form, Visual Studio assigns the TabIndex property in sequence. Most of the time that order is correct, but if you want to tab in some other sequence or if you add controls later, you will need to modify the TabIndex properties of your controls.

20 Setting the Tab Order for Controls (2 of 2)
Users should be able to use the Tab key to move the focus through a form in an organized manner; top to bottom, left to right TabIndex property Number in tab sequence 0 for first control to receive the focus when the form loads Use View Menu, Tab Order to set When your program begins running, the focus is on the control with the lowest TabIndex (usually 0). You may be puzzled by the properties of labels, which have a TabIndex property but not a TabStop. A label cannot receive focus, but it has a location in the tab sequence. This fact allows you to create keyboard access keys for text boxes. When the user types an access key that is in a label, such as Alt + N, the focus jumps to the first TabIndex following the label (the text box). To use a keyboard access key for a text box, the TabIndex of the label must precede the TabIndex of the text box. 18

21 Setting the TabIndex Property
With the Design window active, select View / Tab Order or click the Tab Order button on the Layout toolbar Click on each control in sequence to set TabIndex property of controls automatically To set the tab order for controls, you can set each control’s TabIndex property in the Properties window. Or you can use Visual Studio’s great feature that helps you set TabIndexes automatically.

22 Setting the Form's Screen Location
You can set the form’s screen position by setting the StartPositionproperty of the form To center a form on the user’s screen, set the StartPosition property to CenterScreen

23 Creating ToolTips Small label that is displayed when user pauses mouse pointer over a control Add a ToolTip Control to Form The new control appears in a new pane, Component Tray that opens at the bottom of the Form Designer After you add the component to your form, each of the form’s controls has a new property Select ToolTip on ToolTip1 property of each control and add Tool Tip comments If you are a Windows user, you probably appreciate and rely on ToolTips, those small labels that pop up when you pause your mouse pointer over a toolbar button or control. To define ToolTips, select the ToolTip tool from the toolbox and click anywhere on the form or double-click the ToolTip tool in the toolbox. You also can add multiline ToolTips. In the ToolTip on ToolTip1 property, click the drop-down arrow. This drops down a white box in which you enter the text of the ToolTip. Type the first line and press Enter to create a second line; press Ctrl + Enter to accept the text (or click somewhere outside the Property window). 19

24 ToolTip Control Component Tray

25 Clearing Text Boxes & Labels
Set Text property equal to an Empty String Empty String is 2 quotation marks with no space between them ("") Use the Clear Method of a Text Box or set Text property to String.Empty nameTextBox.Text = "" messageLabel.Text = "" dataTextBox.Clear( ) messageLabel.Text = String.Empty This empty string is also called a null string or zero-length string. 20

26 Resetting the Focus Places the Insertion Point in a Text Box
Use the Focus Method nameTextBox.Focus( ) As a program runs, you want the insertion point to appear in the text box where the user is expected to type. The focus should therefore begin in the first text box. 21

27 Setting the Checked Property of Radio Buttons and Check Boxes
Selects/Deselects Check Box or Radio Button at design or run time Set Checked property True = Checked, selected False = Unchecked, deselected redRadioButton.Checked = True displayCheckBox.Checked = False The purpose of radio buttons and check boxes is to allow the user to make selections. However, at times you need to select or deselect a control in code. You can select or deselect radio buttons and check boxes at design time (to set initial status) or at run time (to respond to an event). To make a radio button or check box appear selected initially, set its Checked property to True in the Properties window. In code, assign True to its Checked property 22

28 Setting Visibility at Run Time
Make label invisible messageLabel.Visible = False You can set the visibility of a control at run time. You may want the visibility of a control to depend on the selection a user makes in a check box or radio button.

29 Changing the Color of Text
ForeColor and BackColor Properties Use VB Color Constants from the Color Class Type the keyword Color and a period in the editor to view a full color list nameTextBox.ForeColor = Color.Red messageLabel.ForeColor = Color.White Most controls have a ForeColor and a BackColor property. The ForeColor property changes the color of the text; the BackColor property determines the color around the text. Visual Basic provides an easy way to specify a large number of colors. These color constants are in the Color class. If you type the keyword Color and a period in the editor, you can see a full list of colors. 23

30 Changing Multiple Properties of a Control
There are times when you will want to change several properties of a single control Previous to version 4 the entire name (Object, Property) for each statement had to be written, such as: titleTextBox.Visible = True titleTextBox.ForeColor = Color.White titleTextBox.Focus() Now you VB provides With and End With statements

31 With and End With Change several properties at once in Code
Will run more efficiently With titleTextBox .Visible = True .ForeColor = Color.White . Focus( ) End With The statements beginning with and ending with End With are called a With block. The statements inside the block are indented for readability. Although indentation is not required by VB, it is required by good programming practices and aids in readability. 24

32 Concatenation Think of concatenation as "tacking" text strings together Use an ampersand (&) preceded and followed by a space between the two strings messageLabel.Text = "Your name is: " & nameTextBox.Text nameAndAddressLabel.Text = nameTextBox.Text & addressTextBox.Text At times you need to join strings of text. For example, you may want to join a literal and a property. 25

33 Continuing Long Program Lines
For long lines of code it is more readable to continue them on the next line At the end of the line use a Line Continuation Character (a Space, an Underscore and press Enter) greetingsLabel.Text = "Greetings " & nameTextBox.Text & ": " & _ "You have been selected to win a free prize." & _ "Just send us $100 for postage and handling." Basic interprets the code on one line as one statement. You can type very long lines in the Editor window; the window scrolls sideways to allow you to keep typing. However, this method is inconvenient; it isn’t easy to see the ends of the long lines. When a Basic statement becomes too long for one line, use a line continuation character. You can type a space and an underscore, press Enter, and continue the statement on the next line. It is OK to indent the continued lines. The only restriction is that the line-continuation character must appear between elements; you cannot place a continuation in the middle of a literal or split the name of an object or property. 26


Download ppt "Brief description on how to navigate within this presentation (ppt)"

Similar presentations


Ads by Google