Lab 6 Slides - PowerPoint PPT Presentation

1 / 32
About This Presentation
Title:

Lab 6 Slides

Description:

Now: returns a DateTime value that is the current local date and time on this computer. ... Today: returns the current system date. ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 33
Provided by: reha6
Category:
Tags: lab | slides

less

Transcript and Presenter's Notes

Title: Lab 6 Slides


1
Lab 6 Slides
2
In this lab
  • Context Menu
  • Tool Bar
  • Progress bar
  • Status bar
  • LinkLabel

3
1. Context Menu
  • A ContextMenu is a shortcut menu, which you can
    used to give context-specific menu options of a
    specified object item to the user.
  • You can write the code to display the shortcut
    menu, whenever the user right-click on the
    specified control such as textbox, listbox, etc.

4
(No Transcript)
5
(No Transcript)
6
  • Set the ContextMenu property the Form to
    ContextMenu1.
  • Set the ContextMenu property the Label
    ContextMenu2.

7
(No Transcript)
8
Multiple Controls Sharing a Single Context Menu
9
  • Note
  • SourceControl the control that was
    right-clicked.
  • Sender the context menu item that was chosen.

10
2- ToolBars
  • ToolStrips work by adding buttons and images to
    them. The button is then clicked, and an action
    performed.
  • To add a toolbar to the top of your form, locate
    the ToolStrip control

11
ToolBars
  • Double click the ToolStrip control, and it will
    be added to the top of your form
  • You should also notice the ToolStrip object
    appear at the bottom of the window

12
  • Click on your ToolStrip to select it. In the
    property box for the ToolStrip, locate the Items
    (Collection) property

13
  • To add a new button to your ToolStrip, click the
    Add button at the top. The button appears in the
    Members box (ToolStripButton1)

14
  • Notice that the new button has its own list of
    properties, just to the right.
  • To add an image to this new button, locate the
    Image property

15
  • Click OK when you have imported the image.
  • You will be returned to the Item Collection
    Editor.
  • Click OK on this, as well.
  • The ToolStrip on your form will then look like
    this
  • Repeat the steps outlined above, and add some
    more buttons to your ToolStrip. It should then
    look something like this

16
  • Of course, if you click on the buttons nothing
    will happen. We need to write the code that gets
    them to work.
  • Return to the Design environment. Double click
    your first ToolStripbutton to bring up the coding
    window. It should look like this

17
3- Progress bar
  • Progress bars are used to display the progress of
    your application or background tasks.
  • There are three members of the ProgressBar
    control you should know about
  • the Maximum,
  • the Minimum, and
  • the Value properties.

18
(No Transcript)
19
(No Transcript)
20
(No Transcript)
21
4- Status Bar
  • Status Bars are used to display status messages
    at the bottom of the form. They are generally
    used to provide additional information, such as
    page numbers, display a message, etc.

22
(No Transcript)
23
(No Transcript)
24
(No Transcript)
25
   5- LinkLabels
  • LinkLabel
  • Displays links to other resources
  • Files
  • Web pages
  • Behavior similar to web page hyperlink
  • Can change color
  • New
  • Previously visited

26
   LinkLabels
27
   LinkLabels
28
  • 1 ' Fig. 13.8 LinkLabelTest.vb
  • ' Using LinkLabels to create hyperlinks to C\
    drive, www.deitel.com and Notepad
  • 3 Public Class FrmLinkLabel
  • 4
  • 5 ' browse C\ drive
  • 6 Private Sub lnklblCDrive_LinkClicked( _
  • 7 ByVal sender As System.Object, ByVal e
    As _
  • 8 System.Windows.Forms.LinkLabelLinkClicke
    dEventArgs) _
  • 9 Handles lnklblCDrive.LinkClicked
  • 10
  • 11 lnklblCDrive.LinkVisited True
  • 12 System.Diagnostics.Process.Start("C\")
  • 13 End Sub ' lnklblCDrive
  • 14
  • 15 ' load www.deitel.com in Web browser
  • 16 Private Sub lnklblDeitel_LinkClicked( _
  • 17 ByVal sender As System.Object, ByVal e
    As _
  • 18 System.Windows.Forms.LinkLabelLinkClick
    edEventArgs) _
  • 19 Handles lnklblDeitel.LinkClicked

Event handlers call method Startallowing
execution of other programsfrom our application
Method Start can take as arguments either the
file to open (a String) or the application to run
and its command-line arguments (two Strings).
In this event handler method Starttakes two
arguments
29
  • 25 ' run application Notepad
  • 26 Private Sub lnklblNotepad_LinkClicked( _
  • 27 ByVal sender As System.Object, ByVal e
    As _
  • 28 System.Windows.Forms.LinkLabelLinkClick
    edEventArgs) _
  • 29 Handles lnklblNotepad.LinkClicked
  • 30
  • 31 lnklblNotepad.LinkVisited True
  • 32
  • 33 ' run notepad application
  • 34 ' full path not needed
  • 35 System.Diagnostics.Process.Start("notep
    ad")
  • 36 End Sub ' lnklblNotepad_LinkClicked
  • 37
  • 38 End Class ' LinkLabelList

30
   LinkLabels
31
   LinkLabels
32
   LinkLabels
Write a Comment
User Comments (0)
About PowerShow.com