ToolStripDropDownMenu Class
Assembly: System.Windows.Forms (in system.windows.forms.dll)
'Declaration <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ <ComVisibleAttribute(True)> _ Public Class ToolStripDropDownMenu Inherits ToolStripDropDown 'Usage Dim instance As ToolStripDropDownMenu
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ /** @attribute ComVisibleAttribute(true) */ public class ToolStripDropDownMenu extends ToolStripDropDown
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) ComVisibleAttribute(true) public class ToolStripDropDownMenu extends ToolStripDropDown
ToolStripDropDownMenu is the base class for ContextMenuStrip, providing necessary painting and layout properties and methods. The properties of this class that you are most likely to use directly are the ShowCheckMargin and ShowImageMargin properties, which determine whether the shortcut menu will be able to display a check mark, an image, or both.
The following code example demonstrates how to create and initialize a ContextMenuStrip control by setting the check and image margins. For a full code listing, see How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls.
Public Sub New() ' Size the form to show three wide menu items. Me.Width = 500 Me.Text = "ToolStripContextMenuStrip: Image and Check Margins" ' Create a new MenuStrip control. Dim ms As New MenuStrip() ' Create the ToolStripMenuItems for the MenuStrip control. Dim bothMargins As New ToolStripMenuItem("BothMargins") Dim imageMarginOnly As New ToolStripMenuItem("ImageMargin") Dim checkMarginOnly As New ToolStripMenuItem("CheckMargin") Dim noMargins As New ToolStripMenuItem("NoMargins") ' Customize the DropDowns menus. ' This ToolStripMenuItem has an image margin ' and a check margin. bothMargins.DropDown = CreateCheckImageContextMenuStrip() CType(bothMargins.DropDown, ContextMenuStrip).ShowImageMargin = True CType(bothMargins.DropDown, ContextMenuStrip).ShowCheckMargin = True ' This ToolStripMenuItem has only an image margin. imageMarginOnly.DropDown = CreateCheckImageContextMenuStrip() CType(imageMarginOnly.DropDown, ContextMenuStrip).ShowImageMargin = True CType(imageMarginOnly.DropDown, ContextMenuStrip).ShowCheckMargin = False ' This ToolStripMenuItem has only a check margin. checkMarginOnly.DropDown = CreateCheckImageContextMenuStrip() CType(checkMarginOnly.DropDown, ContextMenuStrip).ShowImageMargin = False CType(checkMarginOnly.DropDown, ContextMenuStrip).ShowCheckMargin = True ' This ToolStripMenuItem has no image and no check margin. noMargins.DropDown = CreateCheckImageContextMenuStrip() CType(noMargins.DropDown, ContextMenuStrip).ShowImageMargin = False CType(noMargins.DropDown, ContextMenuStrip).ShowCheckMargin = False ' Populate the MenuStrip control with the ToolStripMenuItems. ms.Items.Add(bothMargins) ms.Items.Add(imageMarginOnly) ms.Items.Add(checkMarginOnly) ms.Items.Add(noMargins) ' Dock the MenuStrip control to the top of the form. ms.Dock = DockStyle.Top ' Add the MenuStrip control to the controls collection last. ' This is important for correct placement in the z-order. Me.Controls.Add(ms) End Sub
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Reference
ToolStripDropDownMenu MembersSystem.Windows.Forms Namespace
ContextMenuStrip Class
ToolStripDropDown Class
Other Resources
ToolStrip Control Overview (Windows Forms)ToolStrip Control Architecture
ToolStrip Technology Summary
How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls