In This Article

Context Menu Customization

Property grid item (category, property, etc.) context menus displayed by this product can be customized or replaced entirely before they are shown to the end user.

Default Category Menu

A default context menu can be pre-configured if the PropertyGrid.IsDefaultItemContextMenuEnabled property is set to true.

The default context menu for a category has a menu item for toggling the display of the summary area, if that feature is enabled via PropertyGrid.IsSummaryToggleAllowed.

Default Property Menu

A default context menu can be pre-configured if the PropertyGrid.IsDefaultItemContextMenuEnabled property is set to true.

The default context menu for a property has a menu item for resetting the value to its default, if the control determines the property has been modified.

When the PropertyGrid.AreClipboardMenuItemsEnabled property is true, several clipboard-related menu items are added. One copies the display name of the property, while another copies the value to the clipboard. Another allows for pasting in of a value from the clipboard.

The context menu also has a menu item for toggling the display of the summary area, if that feature is enabled via PropertyGrid.IsSummaryToggleAllowed.

Customizing the Menu or Items

The customization of context menus is handled via the PropertyGrid.ItemMenuRequested event. This event is raised whenever a context menu is displayed for an item in the property grid.

The event arguments passed are of type TreeListBoxItemMenuEventArgs, which indicates the IDataModel for which the event was fired in its Item property. This IDataModel could be an ICategoryModel, IPropertyModel, or ICategoryEditorModel.

Any pre-configured default menu is passed in the TreeListBoxItemMenuEventArgs.Menu property. Its menu items can be changed or removed, or new menu items added.

The default menu is built with all native controls such as ContextMenu and MenuItem. This means that custom styles targeting those types can be applied.

If you wish to completely replace the default menu and supply a custom one, set the TreeListBoxItemMenuEventArgs.Menu property to a menu of your own.