Menus and Display Bars

In order to provide functionality within your application that may need to span a broader scope than a single control within the form, Visual Studio includes the ability to specify several types of menu and display bar classes.

Creating Menus and Menu Items

Menus are used in order to group commonly available and less used functions into a user -friendly format. The MainMenu , ContextMenu , and MenuItem classes are all derived from the Menu class. There may only be a single main menu for an application, whereas a context menu may be associated with each control if desired, in order to provide commands or information related to the control. Table 2.25 details the important members of the MenuItem class.

Table 2.25. Important Members of the MenuItem Class

Member

Type

Description

Checked

Property

Specifies whether a check mark or radio button should appear near the menu item.

Click

Event

Fired when the user clicks on the menu item.

DrawItem

Event

Occurs when a request is made to draw an owner-drawn menu item. DrawItem only occurs when the OwnerDraw property is True.

Enabled

Property

Specifies whether the menu item is enabled.

MenuItems

Property

The collection of MenuItem objects associated with this menu item. By assigning a collection of menu items to an individual menu item, you can create a hierarchical submenu.

OwnerDraw

Property

Specifies whether you can provide custom code to draw a menu item instead of allowing Windows to handle it in a standard way.

Parent

Property

The parent menu with which this menu item is associated. A parent must be specified for a MenuItem object or else it will not be displayed.

PerformClick

Method

Fires the Click event for the MenuItem object as if the user has clicked it.

Popup

Event

Occurs just before displaying a submenu corresponding to this menu item. This event handler is generally used to add, remove, enable, disable, check, or uncheck menu items, depending on the state of an application when they are displayed.

RadioCheck

Property

Specifies whether the menu item should display a radio button instead of a check mark when its Checked property is set to True.

Select

Event

Fired when the user selects a menu item by navigating to it.

Shortcut

Property

The shortcut key combination associated with this menu item.

Text

Property

The text that appears on the menu item.

StatusBar

The StatusBar control is typically used to display information such as a message to the user or application status messages. You may be familiar with the Windows Taskbar, which is similar to a status bar for your operating system. By convention, StatusBar controls are typically docked along the bottom edge of a form and used to provide information and feedback useful to the user. If you set the z-order of the StatusBar control to Send to Back, then the control will not block other controls at the bottom of the form.

One of the more important properties of a StatusBar control is the Panels property, which is a collection of StatusBarPanel objects that may be used to divide the StatusBar into multiple functional areas so that one might display the current editing status while another displays the date and time. Table 2.26 details the important members of the StatusBarPanel class.

Table 2.26. Important Members of the StatusBarPanel Class

Member

Type

Description

Alignment

Property

Alignment of the text and icon within the panel: Center, Left, or Right.

AutoSize

Property

Specifies how the panel is going to size itself. Values are None (the size is fixed when the panel is created), Contents (the panel sizes itself to fit its contents), and Spring (the panel sizes itself to fill the available space).

BorderStyle

Property

The border style to be used: None, Raised, or Sunken.

Icon

Property

The icon displayed in the status bar (always displayed to the left of the text).

Style

Property

Specifies whether the StatusBarPanel object is OwnerDraw or Text (system-drawn). The OwnerDraw style can be used to give custom rendering to a StatusBarPanel object.

ToolTipText

Property

Specifies the ToolTip.

ToolBar

The ToolBar control is usually docked at the top of a form just below its menu bar. Each ToolBar control is typically used to group tools of similar function together, such as text-editing and formatting tools or image-editing tools. If you use the Microsoft Office suite of products, you are likely very familiar with ToolBar controls. If you set the z-order of the ToolBar control to Send to Back, then the control will not block other controls at the top of the form. Table 2.27 details the important members of the ToolBar class.

Table 2.27. Important Members of the ToolBar Class

Member

Type

Description

ButtonClick

Event

Fires when a toolbar button is clicked.

Buttons

Property

A collection of ToolBarButton objects. Each toolbar button represents a button on the ToolBar object.

ImageList

Property

The ImageList object storing icons that will be displayed on ToolBarButton objects.

SendToBack

Method

Sends the toolbar to the back of the z-order.

ShowToolTips

Property

Specifies whether the toolbar should show ToolTips.



Developing and Implementing WindowsR-based Applications with Visual BasicR. NET and Visual StudioR. NET Exam CramT 2 (Exam 70-306)
Developing and Implementing WindowsR-based Applications with Visual BasicR. NET and Visual StudioR. NET Exam CramT 2 (Exam 70-306)
ISBN: N/A
EAN: N/A
Year: 2002
Pages: 188

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net