more user interface controls user interface controls are located in the toolbox. click the +/- signs...

20
More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox.

Upload: avis-burke

Post on 17-Jan-2016

223 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

More User Interface Controls

• User interface controls are located in the toolbox.

• Click the +/- signs to open/ close the different tabs of the tollbox.

Page 2: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Text Boxes/ Rich Text Boxes

• Allow for user input

• Text property indicates what is displayed or entered

MessageTextBox.Text = “Bazinga!”

• TextAlign property controls the layout MessageTextBox.TextAlign = HorizontalAlignmentLeft

• Other useful properties: WordWrap, MultiLine, and BorderStyle

Page 3: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Masked Text Boxes

• A specialized form of the text box that restricts user input to conform to a mask.

• Mask is chosen from the Input Mask dialog box

• Users cannot enter characters that do not conform to the mask.

Page 4: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Group Boxes

• Used as a container for other controls such as radio buttons and check boxes

• Improves readability of form by separating the controls into logical groups

• Text property indicates the words that appear along the top edge of the box.

Page 5: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Check Boxes

• Allow the user to select or deselect one or more items

• Checked property can be set at design time or run time to either True or False For example:

• Use the Text property for the text you want to appear next to the box.

PizzaCheckBox.Checked=False

Page 6: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Radio Buttons

• 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 has values of True or False which can be set at design time or runtime For example:

• Text property

• What is displayed next to the radio button

RedRadioButton.Checked=True

Page 7: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Picture Boxes

• Displays/contains an image

• Image property• Complete path and filename of graphic; images should be added to a

project’s resources

• Allowed image types: .bmp, .gif, .jpg, .jpeg, .png, .ico, .emf, .wmfLogoPictureBox.Image = My.Resources.CompanyLogo

• SizeMode property• StretchImage causes picture to be resized to match the size of the control

• Visible property which can be set to False to make the picture disappear

Page 8: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Selecting Multiple Controls

Use the mouse to drag a selection box around multiple controls.

When multiple controls are

selected, each has resizing

handles (if resizable).

Shift-Click or Ctrl-Click to select/deselect multiple controls.To deselect all selected controls, click elsewhere on the form.

Page 9: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

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 of multiple controls

•Use Format Menu or Layout Toolbar to

• Align controls to each other

• Make controls the same size

• Modify the spacing between controls

Page 10: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

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— use group controls

• Sans Serif fonts work best (no boldface or large)

• Gray is a neutral color that works well

• Keyboard Accessible

Page 11: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Keyboard Access Keys (Hot Keys)

• Many people prefer to use the keyboard, rather than a mouse, for many operations.

• Denoted by an underlined letter

• User presses Alt + underlined letter

• Defined using Text property with & preceding access keyText=&OK

Text=E&xit

Page 12: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Setting the Tab Order of Controls

• One control on a form always has the focus

• Not all control types receive focus.• Text boxes, buttons — have focus

• Picture boxes ,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.

Page 13: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Setting the TabIndex Property

Page 14: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Setting the Form’s Screen Location

• The StartPosition property determines where the form initially appears on the screen.

• For example, use a value of CenterScreen to make the form appear centered in the window.

Page 15: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

ToolTips

• Tooltips are small labels that are displayed when the user pauses the mouse pointer over a control

• Drag a ToolTip Control to the form.

• The new control appears in a new pane, the Component Tray, which 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 the ToolTip on ToolTip1 property of each control and add the text of the tip.

Page 16: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Clearing Text Boxes and Labels

NameTextBox.Text = ""NameTextBox.Clear() NameTextBox.Text = String.Empty

• Text boxes and labels can be cleared several different ways.

• The following clears NameTextBox in three different ways:

Page 17: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Changing the Color of Text

• Properties ForeColor and BackColor change the foreground and background colors of text.

• VB color constants are available from the Color Class For example:

To view the full color list, type the class Color and a period in the editor.

• May be set at either design time or run time. For example:

Color.AliceBlueColor.AntiqueWhiteColor.Blue

NameTextBox.ForeColor=Color.Red

Page 18: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Changing Multiple Properties of a Control

• Sometimes 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. For example”

TitleTextBox.Visible = True

TitleTextBox.ForeColor = Color.White

TitleTextBox.Focus()

• Now, you can use the With and End With statements:

• This runs more efficiently than the longhand version.

With TitleTextBox.Visible=True.ForeColor=Color.White.Focus( )

End With

Page 19: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

String Concatenation

• Concatenation is connecting text strings together.

• Use an ampersand (&) to connect the strings. For example:

• Always make sure there’s whitespace surrounding the &.

FullLabel.Text = FirstLabel.Text & LastLabel.Text

Page 20: More User Interface Controls User interface controls are located in the toolbox. Click the +/- signs to open/ close the different tabs of the tollbox

Continuing Long Program Lines

• Normally, one VB statement is written as one line of code. But sometimes the lines of code get very long.

• The Line Continuation Character (_), lets you continue a line of code on another line. For example,

• If you break up a line of code at a string concatenation character (&), implicit continuation is permitted.

x = 1 + 2 + 3 + 4 + 5 + _ 6 + 7 + 8 + 9 + 10

GreetingsLabel.Text="Greetings " & NameTextBox.Text & ":" &

"You have been selected to win a free prize. "