Professional Documents
Culture Documents
User Interface Design
User Interface Design
2
Outline
Message Box
Text Box
Picture Box
Check Box
Radio Button
Group Box
Keyboard Accessing Key
Tab Order
Setting Form’s Screen Location
Tooltips
3
Message Box
MessageBox.Show(…) display a message box
4
Message Box
TextMessage
◦ String literal or variable that displays message
TitlebarText
◦ String that appears in title bar of message box
MessageBoxButtons
◦ MessageBoxButtons.OK
◦ MessageBoxButtons.OKCancel
◦ MessageBoxButtons.RetryCancel
◦ MessageBoxButtons.YesNo
◦ MessageBoxButtons.YesNoCancel
◦ MessageBoxButtons.AbortRetryIgnore
We will talk about how to know which button is clicked by the user in later lecture
5
Message Box
MessageBoxIcon
◦ MessageBoxIcon.Asterisk
◦ MessageBoxIcon.Error
◦ MessageBoxIcon.Exclamation
◦ MessageBoxIcon.Hand
◦ MessageBoxIcon.Information
◦ MessageBoxIcon.None
◦ MessageBoxIcon.Question
◦ MessageBoxIcon.Stop
◦ MessageBoxIcon.Warning
6
Forms, Controls, and Properties
Forms can have several different types of
controls such as text boxes, picture boxes,
check boxes, radio buttons, and group boxes
7
Text Box (Properties)
Allows for user input
◦ A form can have more than one text box
Text property
◦ Set what is displayed in the text box initially
◦ Indicate what the user entered in the text box
MessageLabel.Text = InputTextBox.Text
(if input is “Hello”, the property of the InputTextBox.Text is “Hello”)
TextAlign property
◦ Controls alignment of text in the text box
InputTextBox.TextAlign = HorizontalAlignment.Left
ReadOnly property
◦ True: cannot be edited by the user directly
But it can still be edited by the VB code
◦ False: can be edited by the user directly
8
Clearing Text Boxes and Labels
Set Text property equal to an Empty String
InputTextBox.Text = ""
◦ An empty string is two double quotation marks with no
space between them (i.e., "")
◦ It is also called a null string or zero-length string
9
Picture Box
Displays or contains an image
Image property
◦ Complete path and filename of the image
◦ Some possible extensions of the image:
.gif, .jpg, .jpeg, .bmp, .wmf, .png
SizeMode property
◦ StretchImage: causes the picture to be resized to match the size of the control
Visible property
◦ True / False: make the picture appear / disappear
◦ LogoPictureBox.Visible = True
10
Check Box
Allows the user to select or deselect zero or more items in any group
Use the Text property for the text we want to appear next to the box
Checked property
◦ True: the check box is checked
◦ False: the check box is not checked
11
Radio Button
User may select at most one in any group
Use the Text property for the text we want to appear next to the
button
Checked property
◦ True: the radio button is selected
◦ False: the radio button is not selected
12
Radio Button
If we want to have two groups of radio
buttons, we have to
◦ First, create two group boxes (see next page)
◦ Then, create radio buttons inside each group box
13
Group Box
Improves readability of the form by separating the
controls into logical groups
14
Keyboard Access Keys
Some people prefer to use the
keyboard (rather than the mouse)
for most operations
◦ Hot Keys (press Alt + hotkey)
Text=&OK
Text=E&xit
15
Setting the Tab Order for Controls (1
of 3)
The control that has the focus can receive input from the keyboard
◦ At each time, at most one control can have the focus
◦ We can change the focus by pressing “Tab” on the keyboard
TabStop property can be applied only for controls that are capable
of receiving the focus by using “Tab”
◦ True: allow it to receive the focus
◦ False: do not allow it to receive the focus
16
Setting the Tab Order for Controls (2
of 3)
Users should be able to use the
Tab key to move the focus
through a form in an organized
manner
◦ Top to bottom and left to right
17
Setting the Tab Order for Controls (3
of 3)
Instead of modifying
the properties of each
control one by one,
we can use Tab Order
in the View menu
◦ Click on each control in
sequence to set
TabIndex property of
the controls
18
Setting the Form’s Screen Location
We can set the form’s screen position by
setting the StartPosition property of the Form
19
Creating ToolTips
Small label that is displayed when the user
pauses the mouse pointer over a control
◦ Add a ToolTip control to a Form
◦ The new control appears in a Component Tray,
which opens at the bottom of the Form Designer
◦ After we add the component to the form, each of
the form’s controls has a new property
◦ Select ToolTip on ToolTip1 property of each control
and add Tool Tip comments
20
Component Tray
Component Tray
21
Tips for Designing the User Interface
The design of the screen should be easy to understand and
“comfortable” for the user
◦ Follow industry standards for the color, size, and placement of controls
◦ Match other Windows applications
22
References and Readings
Programming in Visual Basic 2010.
◦ Bradley and Millspaugh, McGraw-Hill
◦ Chapter 2: User Interface Design.
23