Distance Learning Center - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Distance Learning Center

Description:

Menus consist of a menu bar containing menus, each of which drops down to ... at the top of the form; To deactivate the menu by clicking elsewhere on the form. ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 31
Provided by: melis76
Category:

less

Transcript and Presenter's Notes

Title: Distance Learning Center


1
Distance Learning Center
  • Lecture 10
  • Introduction to Visual Basic
  • Programming
  • Melissa Lin, IT Consultant
  • HenEm, Inc. Parkville, Missouri
  • linm_at_ipfw.edu
  • http//www.etcs.ipfw.edu/linm

2
Lecture 10
  • Menus
  • Designer
  • Submenus
  • Properties
  • Dialog Boxes
  • Color
  • Font

3
Menus
  • Menus consist of a menu bar containing menus,
    each of which drops down to display a list of
    menu items.
  • Designer to define and develop menus and menu
    items to the form
  • Properties to hold attributes of each object
  • Submenus - a menu within a menu
  • Each menu Item has name properties and click
    events

4
Menus
  • Add Menu Items control to a form
  • You must add a MainMenu control from the toolbox
  • Type text over the word Type Here appear at the
    top of the form
  • Then the words Type Here appear both below the
    menu name and to the right of the menu name
  • Add submenu by moving to the right of a menu
    item and typing the next items text.
  • Drop-down list of commands
  • Have name properties
  • Have click events to write code
  • Note To activate the menu designer by clicking
    on the menu at the top of the form To deactivate
    the menu by clicking elsewhere on the form.

5
Creating a Menu
  • MainMenu
  • Create menus
  • Use keyboard access commands (x) - Alt-x

Type name of menu
MainMenu control added to Form
6
Creating a Menu Sub Menu
Type File
Create submenus by moving to the right of a menu
item and typing the next item's text
7
Define Property
Type filePrintMneuItem
Type fileMenu
Type Print
Type File
8
Separator Bar
  • To insert a separator bar, right-click on the
    menu designer where you want the separator bar to
    appear and choose Insert Separator from the
    context menu.

9
Hands-On Creating a Menu
  • The steps to write the project
  • Define the GUI with
  • File, Edit, Display Help
  • Print Style Summary
    About
  • Exit Font Instruction
  • Color
  • Have a separator bar inside Display menu
  • Set the properties of each object as you have
    planned
  • Write the code working from the pseudcode,
    write each event procedure
  • When completed, to ensure the tab order is set
    correctly

10
Planning GUI Design
File Edit Display Help
Print Style Summary About

Exit Font Instruction
Color
11
Define GUI
12
Define GUI (continued)
13
Define Properties
14
Coding the Menu
  • Name the menus e.g. fileMenu, fileExitMenuItem,
    helpMenu
  • Each menu item has a Click event
  • Private Sub fileExitMenuItem_Click
  • End Sub
  • Private Sub helpMenu_Click
  • End Sub
  • Menu Item Properties
  • Checked (fileMenu.CheckedFalse)
  • Enabled (fileMenu.EnabledFalse)
  • Visible (fileMenu.VisibleTrue)

15
Coding the Menu (continued)
Private Sub helpAboutMenuItem_Click(ByVal sender
As _ System.Object, ByVal e As System.EventArgs)
Handles _ helpAboutMenuItem.Click
MessageBox.Show("Programmed by Melissa Lin", _
"About My Program", MessageBoxButtons.OK, _
MessageBoxIcon.Information) End Sub
16
Coding the Menu (continued)
Private Sub displaySummaryMenuItem_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles displaySummaryMenuItem.C
lick If DdisplaySummaryMenuItem.Checked
Then 'Hide the summary
displaySummaryMenuItem.Checked False
Else 'show the summary
displaySummaryMenuItem.Checked True End
If End Sub
17
Separator Bars
  • Used for grouping menu items according to their
    purpose
  • Visually represented as a bar across the menu
  • Create using one of two methods
  • Typing a single hyphen for the text
  • Right-click on Menu Designer where you want
    separator bar and choose Insert Separator

18
Menu Design Standards
  • Follow the industry standards for Windows for
    names, order/location, access keys, shortcut keys
  • Basic Main Menus

File Edit View Format Help
  • Standard File Menu
  • New (Ctrl N)
  • Open (Ctrl O)
  • Close
  • Save As
  • Save (Ctrl S)
  • Print (Ctrl P)
  • Exit
  • Standard Edit Menu
  • Undo (Ctrl Z)
  • Cut (Ctrl X)
  • Copy (Ctrl C)
  • Paste (Ctrl V)
  • Find (Ctrl F)
  • Replace (Ctrl H)

19
System Objects and Events
WithEvents helpAboutMenuItem As
System.Windows.Forms.MenuItem
Private Sub helpAboutMenuItem_Click(ByVal sender
As _ System.Object, ByVal e As System.EventArgs)
Handles _ helpAboutMenuItem.Click
MessageBox.Show("Programmed by Melissa Lin", _
"About My Program", MessageBoxButtons.OK, _
MessageBoxIcon.Information) End Sub
20
Common Dialog Boxes
  • Predefined standard dialog boxes for
  • Color selection
  • Font selection
  • (File Opening and Saving)
  • (Printing and Previewing)
  • Add the Common Dialog control to form
  • Appears in the Component Tray, pane at bottom of
    Form Designer where non-display controls are shown

21
Common Dialog Boxes (continued)
ExampleProjDialogBox
22
Color Font Dialog Boxes
Default Font, Style, and Size
Default Color
23
Code to Use Common Dialog Box for Fonts
  • Syntax DialogObject.ShowDialog()
  • Private Sub fontButton_Click(ByVal sender As
    System.Object, ByVal e As System.EventArgs)
    Handles fontButton.Click
  • 'Change Font of Label
  • With FontDialog1
  • .ShowDialog()
  • fontLabel.Font .Font
  • End With
  • End Sub

24
Common Dialog Box
25
Use Common Dialog Box for Color
Private Sub backColorButton_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles backColorButton.Click 'Change
BackColor of Label With ColcoDialog1
.ShowDialog()
fontLabel.BackColor .Color End With End
Sub Private Sub foreColorButton_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnForeColor.Click
'Change ForeColor of Label With
ColorDialog1 .ShowDialog()
fontLabel.ForeColor .Color End
With End Sub
26
Common Dialog Box - BackColor
Click
27
Common Dialog Box - ForeColor
Click
28
Exit Message Box
Private Sub exitButton_Click(ByVal sender As
System.Object, _ ByVal e As System.EventArgs)
Handles exitButton.Click
MessageBox.Show("Exit - DialogBox", _
"Using DialogBox", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
Me.Close() End Sub
29
Summary
  • Menus
  • Designer
  • Submenus
  • Properties
  • Dialog Boxes
  • Color
  • Font
  • Next
  • Context menus
  • Passing Arguments to procedures

30
Question?
  • Answers
  • linm_at_ipfw.edu
Write a Comment
User Comments (0)
About PowerShow.com