VLMenuPlus Reference

EventSetMenuItemAttributes

See Also See Also Applies To Applies To

This event is occurs when a menu item attributes needs to be setup. It is used to setup properties of individual menu items. Use this event when you want to have flexibiliy in appearence of individual menu items.

 

Syntax

Private Sub object _SetMenuItemAttributes( ByVal mnuItem As CMenuItem)

 

The SetMenuItemAttributes event syntax has these parts:

Part Description
object An object expression that evaluates to an object of VLMenuPlus type.
mnuItem A CMenuItem object corresponding to the menu item that needs to be a setup. For details of the properties of mnuItem, refer to CMenuItem documentation.

 

Following code snippets shows the use of this event :

Sample 1


Private Sub VLMenuPlus1_SetMenuItemAttributes(ByVal mnuItem As CMenuItem)
   If (mnuItem.Checked = True) then
      mnuItem.CaptionFont.Bold  = True
      mnuItem.ShortcutFont.Bold  = True
   End If

   If (mnuItem.IsTopLevel = True) Then
      mnuItem.CaptionFont.Name = "Times New Roman"
      mnuItem.ShortcutFont.Name  = "Times New Roman"
   End If
    
   If (mnuItem.Caption = "Zoom") Then
      mnuItem.TooltipText = "Control zoom level of the current document"
   End If

End Sub

In this example, we are setting up all checked menu items to be displayed in bold font. Also we are setting all top level menu items (menu items that appear in the menu bar) to be displayed with Times New Roman font face.

As you can see, changing menu display style at individual menu item level is extremely simple using this event.

 

Sample 2

Private Sub VLMenuPlus1_SetMenuItemAttributes(ByVal mnuItem As CMenuItem)
   Select Case VLMenuPlus1.GetCleanCaption(mnuItem.Caption)
      Case "ZOOM IN"
         Set mnuItem.Picture = PictureBox1.Picture
   End Select

End Sub

In this example, we are setting up picture corresponding to a menu item from a PictureBox object. Instead of a picturebox object you can specify a picture from an ImageList object as well.

 

Note

Please note even if caption of any of the top level menu items matches with the captions specified in default bitmap list, control will not automatically show bitmap next to them. This behavior is by design.

This behavior can be overridden by specifing bitmap for the toplevel menu items in this event. Following code snippet shows how to use default bitmaps for the top level menu items :

 

Sample 3

Private Sub VLMenuPlus1_SetMenuItemAttributes(ByVal mnuItem As CMenuItem)
   If (mnuItem.IsTopLevel) Then
      Set mnuItem.Picture = VLMenuPlus1.GetDefaultPicture(mnuItem.Caption)
   End If
End Sub