User Interface Design
User Interface Design
User Interface Design
The user interface is the link between the user and capabilities of the application. A well-designed user interface
makes easy for the users to learn and use the application.
User interfaces can be roughly categorized into two types
Command-line interfaces use textual input and output i.e. the end user interacts with an application by
typing commands
Most Windows user interfaces are form-based visual interfaces i.e. the end user interacts with an application
through its visual elements
Form Object
The Form is where the user interface is drawn. It is central to the development of Visual Basic applications,
whether for databases or other uses.
Some of Form Properties:
BackColor - controls the background color of the whole screen
Text - the text that appears in the form's title bar
WindowState - controls how big the window is when the program is run
0 Normal 1 Minimized 2 Maximized (best)
Name - the name of the form
eg. change Form1 to TitleScreenForm
FormBorderStyle - controls the appearance of the form. It also determines whether the user can resize
the form
Design and implementation of Computer Applications ~ MO Page 1 of 6
The Width and Height properties define the form’s size (x length and y length)
BackgroundImage property- used to create an effect with a background image. You can alter the
appearance of an image with the backgroundImageLayout property -- setting it to Tile, Center,
Stretch, or Zoom.
StartPosition property – set to CenterScreen to display a form centered on the display at run time.
Fonts - Use a MS Sans Serif font for most information on a form as this font is easiest for most people
to read. Do not use large fonts except for a limited number of items, and do not use bold or italic fonts
except to highlight select information.
Controls
Controls are all instances of control classes and the collection of control classes are arranged in a class hierarchy
i.e. System.Windows.Forms.Form.Control Class
This class is the base class from which all visible controls are derived
Dialog boxes derived from the CommonDialog class
3). TextBox
You use a TextBox control to obtain information from the user or to display information provided by the
application. Unlike information displayed in a label, the user can change information displayed in a text
box. Data entered into a TextBox control is saved to the Text property of the control.
Some properties of text box include: -
ForeColor – color of the text in the control.
BackColor – color of the background – white is the default.
TextAlign – your options are to display the text left, right, or center justified. Left is the default.
Design and implementation of Computer Applications ~ MO Page 2 of 6
Multiline – set to True if the TextBox will display more than one line of text – the default is False.
WordWrap – this property determines if the contents of a TextBox should wrap to a second line (or
subsequent lines) if the output will not fit on a single line – the default is True.
BorderStyle property – this property makes controls appear as either flat or three-dimensional.
ReadOnly – set to True if the TextBox will only display output – the default is False so you can type
text into the TextBox.
Examples:
'Set the text color of the NameTextBox to black
NameTextBox.ForeColor = Color.Black
'Set the color of the text of the for the form to white
NameTextBox.BackColor = Color.White
However, the Clear method is used most often to clear a TextBox or MaskedTextBox. Example:
NameTextBox.Clear()
PhoneMaskedTextBox.Clear()
Note: Format menu – use this to align/size the controls and set vertical/horizontal spacing. Select the
controls by holding down CTRL or SHIFT keys and using the mouse to click each one in order. The first
control selected is the base control which all of the other controls will mirror.
To reset a group of RadioButtons so that one is checked and the others are not checked, you only need to
set the Checked property to True for one of the controls – the others will automatically be set to False.
For CheckBox controls, you must set each of the control's Checked property to the desired value.
Example
To read the Image named "C:\House1.jpg" into the PictureBox control instance named picDemo
picDemo.Image = _
System.Drawing.Image.FromFile( _
"C:\House1.jpg")
Note: Buttons and other controls have an Image property that will cause the display of a graphic on the
control.
Concatenation Operator
ControlChars
The ControlChars.NewLine is a value of the ControlChars (control characters) VB enumeration of values
used to control the output display of information
Example
The code below will make the NameTextBox control visible, set the text colors for foreground and background,
and set the focus to this control.
With NameTextBox
.Visible = True
.ForeColor = Color.Black
.BackColor = Color.White
.Focus()
End With