WinForms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Interface IContextMenuProvider

    Show / Hide Table of Contents

    Interface IContextMenuProvider

    The IContextMenuProvider interface provides Essential Studio controls with a high-level API for creating and working with context menus. Subscribing to this interface allows the Essential Studio controls to seamlessly switch between the standard .NET System.Windows.Forms.ContextMenu and the classes depending on whether the Essential Tools library is available or not. StandardMenusProvider ContextMenuItem

    Namespace: Syncfusion.Windows.Forms
    Assembly: Syncfusion.Shared.Base.dll
    Syntax
    public interface IContextMenuProvider

    Methods

    AddContextMenuItem(String, EventHandler)

    Creates a new top-level menu item.

    Declaration
    void AddContextMenuItem(string itemtext, EventHandler handler)
    Parameters
    Type Name Description
    System.String itemtext

    A System.String value representing the menu item.

    System.EventHandler handler

    The System.EventHandler that will handle the menu item Click event.

    AddContextMenuItem(String, String, EventHandler)

    Creates a new menu item and adds it to the specified parent menu item.

    Declaration
    void AddContextMenuItem(string parentitem, string itemtext, EventHandler handler)
    Parameters
    Type Name Description
    System.String parentitem

    A System.String value representing the parent menu item.

    System.String itemtext

    A System.String value representing the menu item.

    System.EventHandler handler

    The System.EventHandler that will handle the menu item Click event.

    Clear()

    Clears all menu items.

    Declaration
    void Clear()

    DisposeContextMenu()

    Disposes the context menu associated with this provider.

    Declaration
    void DisposeContextMenu()

    GetContextMenuItemChecked(String)

    Gets the menu item's Checked property.

    Declaration
    bool GetContextMenuItemChecked(string itemtext)
    Parameters
    Type Name Description
    System.String itemtext

    A System.String value representing the menu item.

    Returns
    Type Description
    System.Boolean

    A boolean value.

    GetContextMenuItemEnabled(String)

    Indicates the state of the menu item's Enabled property.

    Declaration
    bool GetContextMenuItemEnabled(string itemtext)
    Parameters
    Type Name Description
    System.String itemtext

    A System.String value representing the menu item.

    Returns
    Type Description
    System.Boolean

    A boolean value.

    GetContextMenuItemShortcut(String)

    Returns the menu item's shortcut key.

    Declaration
    Shortcut GetContextMenuItemShortcut(string itemtext)
    Parameters
    Type Name Description
    System.String itemtext

    A System.String value representing the menu item.

    Returns
    Type Description
    System.Windows.Forms.Shortcut

    A System.Windows.Forms.Shortcut key value.

    GetItemsCount()

    Gets the Menu items count.

    Declaration
    int GetItemsCount()
    Returns
    Type Description
    System.Int32

    InitializeContextMenu()

    Creates a new instance of the context menu object managed by this provider.

    Declaration
    void InitializeContextMenu()
    Remarks

    If the provider contains a previously initialized context menu, then the existing menu will be disposed before creating the new menu.

    NeedAddRemoveButtons()

    Indicates whether "Add or Remove buttons" is needed.

    Declaration
    bool NeedAddRemoveButtons()
    Returns
    Type Description
    System.Boolean

    RemoveContextMenuItem(String)

    Removes the specified context menu item.

    Declaration
    void RemoveContextMenuItem(string itemtext)
    Parameters
    Type Name Description
    System.String itemtext

    A System.String value representing the menu item.

    SetContextMenuItemChecked(String, Boolean)

    Sets the menu item's Checked property to the specified value.

    Declaration
    void SetContextMenuItemChecked(string itemtext, bool bchecked)
    Parameters
    Type Name Description
    System.String itemtext

    A System.String value representing the menu item.

    System.Boolean bchecked

    The boolean value to be set.

    SetContextMenuItemEnabled(String, Boolean)

    Sets the menu item's Enabled property to the specified value.

    Declaration
    void SetContextMenuItemEnabled(string itemtext, bool benabled)
    Parameters
    Type Name Description
    System.String itemtext

    A System.String value representing the menu item.

    System.Boolean benabled

    The boolean value to be set.

    SetContextMenuItemImage(String, ImageList, Int32)

    Sets the menu item image.

    Declaration
    void SetContextMenuItemImage(string itemtext, ImageList imagelist, int image)
    Parameters
    Type Name Description
    System.String itemtext

    A System.String value representing the menu item.

    System.Windows.Forms.ImageList imagelist

    The System.Windows.Forms.ImageList containing the image.

    System.Int32 image

    The zero-based image index.

    SetContextMenuItemSeparator(String, Boolean)

    Inserts or removes a separator before the specified menu item's position.

    Declaration
    void SetContextMenuItemSeparator(string itemtext, bool binsertseparator)
    Parameters
    Type Name Description
    System.String itemtext

    A System.String value representing the menu item.

    System.Boolean binsertseparator

    True to insert a new separator; False to remove an existing separator.

    SetContextMenuItemShortcut(String, Shortcut)

    Sets a shortcut key for the menu item.

    Declaration
    void SetContextMenuItemShortcut(string itemtext, Shortcut key)
    Parameters
    Type Name Description
    System.String itemtext

    A System.String value representing the menu item.

    System.Windows.Forms.Shortcut key

    The System.Windows.Forms.Shortcut key for the menu item.

    SetVisualStyle(VisualStyle)

    Sets the visual style for the context menu.

    Declaration
    void SetVisualStyle(VisualStyle style)
    Parameters
    Type Name Description
    VisualStyle style

    A VisualStyle value.

    ShowContextMenu(Control, Point)

    Displays the context menu at the specified position.

    Declaration
    void ShowContextMenu(Control owner, Point pt)
    Parameters
    Type Name Description
    System.Windows.Forms.Control owner

    A System.Windows.Forms.Control object that specifies the control with which this context menu is associated.

    System.Drawing.Point pt

    A System.Drawing.Point object that specifies the coordinates at which to display the menu.

    Events

    Collapse

    Occurs when menu is collapsed.

    Declaration
    event EventHandler Collapse
    Event Type
    Type Description
    System.EventHandler

    Popup

    Occurs when menu is popped up.

    Declaration
    event EventHandler Popup
    Event Type
    Type Description
    System.EventHandler
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved