Lecture 6 - Menus (2)(vb 2008)

  • Uploaded by: curlicue
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Lecture 6 - Menus (2)(vb 2008) as PDF for free.

More details

  • Words: 407
  • Pages: 10
Lecture 6: Creating Menus (Cont)

Introduction 

In Lecture 5 , we discussed the MenuStrip Control, which: 

Allows you to add Menus, Menu Items, and SubMenu Items…  



We also used the Menu Editor : 



Including the addition of Access Keys and Shortcut Keys As well as Check Marks Which allowed us to Add, Change, and Delete Menu Items.

In this lecture, we continue our discussion of Menus, by : 

Finishing our QuickMenu Project  



Coding the Main (but not the Formatting) ToolStrip Testing our MenuStrip’s Functions

Discussing Context Menus: 

A second type of ‘drop-down’ menu also supported by VB .NET

Coding the Main ToolStrip

Testing the Menu’s Functions

Context Menus 

When you point at TextBox1 and … 

You will notice that a drop-down menu pops up automatically:



This Context Menu provides many of the behaviors we just coded…  



However, we did not code this menu Furthermore, the Event Handlers we coded are not used here…

Instead this default Context Menu is provided automatically by Windows:  

Whenever we on a Control or Window. These support default, customized management of the selected Control 



For TextBoxes: Undo, Cut, Copy, Paste, Delete, etc.

VB .NET provides a method to Override such default menus: 

Allowing you to restrict functionality (e.g., no copying operation).

The ContextMenuStrip Control 

VB .NET provides a ContextMenuStrip Control for Developers 

As usual, it can be placed on your Form directly… 



The ContextMenuStrip is quite similar to the MenuStrip Control…  



By being dragged from the ToolBox. It can be set up and customized in just the same way. However, it supports only 1 Top-level Menu.

Most Controls in the ToolBox have a ContextMenu Property 

This allows you to define a ContextMenuStrip for use with that Control. 

When you click the Property, you may select your own ContextMenu… 



Rather than the Default.

Note: some Controls do NOT have a default ContextMenu 

These are generally Controls that contain a List of Items (not just one item). 



e.g.: ComboBoxes, ListBoxes

However, they still have a ContextMenu Property that can be set.

ContextMenu Example (1) 

To demonstrate, let’s add a ContextMenuStrip to our Project: 

We will code it to duplicate some convenient functions of our MenuStrip.

ContextMenu Example (2)

ContextMenu Ex (3)

ContextMenu Example (4)

Related Documents

Menus
June 2020 18
Menus
December 2019 40
Menus
October 2019 26
Menus
June 2020 12

More Documents from ""