RadMenu
Represents a menu. RadMenu can be horizontal or vertical. You can add, remove, and disable menu items at run-time. It offers full theming support, allowing you to easily construct a variety of stunning visual effects. You can nest any other RadControl within a RadMenu. For example, you can create a menu with an embedded textbox or combobox.
RadMenu is a simple wrapper for the RadMenuElement class.
Definition
Namespace:Telerik.WinControls.UI
Assembly:Telerik.WinControls.UI.dll
Syntax:
[TelerikToolboxCategory("Menus & Toolbars")]
[DefaultBindingProperty("Items")]
public class RadMenu : RadItemsControl, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IComponent, IDisposable, INotifyPropertyChanged, ISupportInitializeNotification, ISupportInitialize, IComponentTreeHandler, ILayoutHandler, IAnalyticsProvider, IItemsControl, IMessageListener
Inheritance: objectMarshalByRefObjectComponentControlScrollableControlRadControlRadItemsControlRadMenu...
Implements:
Inherited Members
Constructors
Initializes a new instance of the RadMenu class. RadMenu can be horizontal or vertical. You can add, remove, and disable menu items at run-time. It offers full theming support, allowing you to easily construct a variety of stunning visual effects. You can nest any other RadControl within a RadMenu. For example, you can create a menu with an embedded textbox or combobox.
public RadMenu()
Properties
Gets or sets a value indicating whether all menu items will appear with the same height, using the height of the tallest item in the collection.
[Browsable(true)]
public bool AllItemsEqualHeight { get; set; }
Gets or sets a value indicating whether this menu allows merging with other RadMenu instances to create a unified menu structure.
public bool AllowMerge { get; set; }
Gets or sets a value indicating whether the menu automatically adjusts its size to fit its content.
public override bool AutoSize { get; set; }
Overrides:
Gets or sets the background color of the menu. Note that RadMenu consists of multiple visual elements and separate settings are provided to customize their appearance, so this property might be ignored.
public override Color BackColor { get; set; }
Overrides:
Gets the default size of the control.
protected override Size DefaultSize { get; }
Overrides:
Gets or sets which edge of the parent container the menu is docked to.
public override DockStyle Dock { get; set; }
Overrides:
Gets or sets the easing type used for dropdown animations when DropDownAnimationEnabled is true.
[Browsable(true)]
public RadEasingType DropDownAnimationEasing { get; set; }
Gets or sets a value indicating whether dropdown animations are enabled when submenu items are displayed.
[Browsable(true)]
public bool DropDownAnimationEnabled { get; set; }
Gets or sets the number of frames used for dropdown animations when DropDownAnimationEnabled is true.
[Browsable(true)]
public int DropDownAnimationFrames { get; set; }
Gets or sets a value indicating whether this RadMenu handles MDI (Multiple Document Interface) menu functionality and system buttons for child forms.
[Browsable(true)]
public bool IsMainMenu { get; set; }
Gets the collection of root menu items that are displayed in the menu. Root items are top-level menu items that have no parent item and can contain child items as submenus.
[RadEditItemsAction]
[RadNewItem("Type here", true, true, false)]
[Browsable(true)]
public override RadItemOwnerCollection Items { get; }
Overrides:
Gets the instance of RadMenuElement wrapped by this control. RadMenuElement is the main element in the hierarchy tree and encapsulates the actual functionality of RadMenu.
[Browsable(false)]
public RadMenuElement MenuElement { get; }
Gets or sets the Orientation of menu items, determining whether they are arranged horizontally or vertically.
[Browsable(true)]
public Orientation Orientation { get; set; }
Gets or sets a value indicating whether keystrokes that do not match any registered mnemonic are propagated
to other controls while the menu's keyboard cues are visible (i.e. after the Alt key is pressed).
When false, such keystrokes are consumed by the menu and not dispatched to other controls such as a
focused text box. The default is true, preserving existing behavior.
[Browsable(true)]
public bool PropagateNonMnemonicKeys { get; set; }
Gets or sets a value indicating whether menu items should be stretched to fill the available space in the menu.
[Browsable(true)]
public bool StretchItems { get; set; }
Gets or sets a value indicating whether the Alt or F10 keys can be used to highlight and activate the menu for keyboard navigation.
[Browsable(true)]
public bool SystemKeyHighlight { get; set; }
Methods
Determines whether the base ProcessDialogKey(Keys) implementation should handle the key. Always returns false, since dialog keys are fully handled by this menu.
Determines whether the specified menu item can currently be processed (selected/clicked).
protected virtual bool CanProcessItem(RadMenuItemBase menuItem)
The RadMenuItemBase to check.
Returns:True if the item is non-null and enabled; otherwise, false.
Determines whether the specified character can be processed as a mnemonic for any menu item.
Creates an accessibility instance for the menu control to support assistive technologies and screen readers.
protected override AccessibleObject CreateAccessibilityInstance()
An AccessibleObject that provides accessibility support for the menu control.
Overrides:
Creates and initializes the child elements of the menu, including the RadMenuElement and its event handlers.
protected override void CreateChildItems(RadElement parent)
The parent element to add child elements to.
Overrides:
Creates the root element of the control.
protected override RootRadElement CreateRootElement()
A new RadMenu.RadMenuRootElement instance.
Overrides:
Releases the resources used by the control, unregistering the message filter listener and detaching form/items event handlers.
protected override void Dispose(bool disposing)
True to release both managed and unmanaged resources; false to release only unmanaged resources.
Overrides:
Recursively finds the deepest currently selected item across this menu and any shown child popups.
protected virtual RadMenuItemBase GetCurrentProcessedItem(IItemsControl itemsControl)
The IItemsControl to search.
Returns:The deepest selected RadMenuItemBase, or null if none is selected.
Recursively searches for the menu item, including nested drop-down items, whose mnemonic matches the specified character.
protected virtual RadMenuItemBase GetSysCharItem(IItemsControl itemsControl, char searchKey)
The IItemsControl to search.
searchKeycharThe mnemonic character to match.
Returns:The matching RadMenuItemBase, or null if none is found.
Initializes the root element with default property values for the menu.
protected override void InitializeRootElement(RootRadElement rootElement)
The root element to initialize.
Overrides:
Merges the specified RadMenu with this menu, combining their menu items according to merge settings.
public virtual void MergeMenu(RadMenu sourceMenu)
The source RadMenu to merge into this menu.
Exceptions: ArgumentExceptionThrown when attempting to merge a menu with itself.
Raises the AllItemsEqualHeightChanged event when the equal height setting for menu items changes.
Handles item deselection, updating whether child items should continue to be shown based on the deselected item's popup and enabled state.
protected override void OnItemDeselected(ItemSelectedEventArgs args)
An ItemSelectedEventArgs that contains the event data.
Overrides:
Handles item selection, marking the item as selected and notifying accessibility clients.
protected override void OnItemSelected(ItemSelectedEventArgs args)
An ItemSelectedEventArgs that contains the event data.
Overrides:
Handles control load, subscribing to the parent form's Deactivate event and registering with the RadMessageFilter to track menu-wide mouse activity.
protected override void OnLoad(Size desiredSize)
The desired size of the control.
Overrides:
Called when the menu state changes, handling the transition between different RadMenu.RadMenuState values.
protected virtual void OnMenuStateChanged(RadMenu.RadMenuState oldState, RadMenu.RadMenuState newState)
The previous RadMenu.RadMenuState.
newStateRadMenu.RadMenuStateThe new RadMenu.RadMenuState.
Handles the mouse down event, activating the menu item located at the click position.
protected override void OnMouseDown(MouseEventArgs e)
A MouseEventArgs that contains the event data.
Overrides:
Handles the mouse move event, updating item selection and showing/hiding child popups as the pointer moves between menu items.
protected override void OnMouseMove(MouseEventArgs e)
A MouseEventArgs that contains the event data.
Overrides:
Raises the OrientationChanged event when the menu orientation changes.
Raises the TextOrientationChanged event when the text orientation property value changes.
Activates keyboard-driven selection state and selects the specified menu item in response to a mouse-down interaction.
protected virtual void PerformMouseDown(RadMenuItemBase menuItem)
The RadMenuItemBase under the mouse pointer.
Preprocesses a raw mouse Windows message, deactivating the currently shown keyboard-cue selection when the pointer moves outside the active item's bounds.
protected virtual void PreprocessMouseEvent(ref Message msg)
The raw mouse message to preprocess.
Processes an arrow key press, dispatching to left/right or up/down navigation logic based on the menu's Orientation.
Does nothing; the menu's size is managed entirely by its layout rather than by the AutoSize mechanism.
protected override void ProcessAutoSizeChanged(bool value)
True if AutoSize is enabled; otherwise, false.
Overrides:
Processes command keys, deactivating the menu and deselecting the current item when Escape is pressed while no popups are open.
protected override bool ProcessCmdKey(ref Message m, Keys keyData)
A Message, passed by reference, that represents the window message to process.
keyDataKeysOne of the Keys values that represents the key to process.
Returns:True if the command key was processed by this method; otherwise, the result of the base implementation.
Overrides:
Processes Coded UI test messages, exposing the item count and child-node presence for automated testing scenarios.
protected override void ProcessCodedUIMessage(ref IPCMessage request)
The IPC message containing the test command and parameters.
Overrides:
Processes dialog keys, activating the selected item's click or closing its popup when the Enter key is pressed.
Handles the first stage of system-key (Alt) mnemonic activation, toggling the menu's keyboard-cues visible state.
Determines whether the specified element should receive focus. Always returns false, since focus is managed internally by the menu.
protected override bool ProcessFocusRequested(RadElement element)
The RadElement requesting focus.
Returns:Always false.
Overrides:
Processes the left or right arrow key, moving selection between top-level items and showing the newly selected item's child popup when applicable.
Processes a mnemonic character, selecting the matching menu item when the menu is displaying keyboard cues.
Handles the second stage of system-key mnemonic activation, including the F10 key, toggling the menu's keyboard-active selection state.
Processes the up or down arrow key, expanding the current item's child popup when applicable.
Resets theme value overrides for the BackColor property, restoring default theme behavior.
protected override void ResetBackColorThemeOverrides()
Overrides:
Sets theme value overrides for the BackColor property of the menu.
protected override void SetBackColorThemeOverrides()
Overrides:
Sets the current state of the menu for mnemonic and keyboard processing.
public void SetMenuState(RadMenu.RadMenuState state)
The RadMenu.RadMenuState to set for the menu.
Events
Occurs when the AllItemsEqualHeight property value changes, indicating a change in the height uniformity setting for menu items.
public event EventHandler AllItemsEqualHeightChanged
Occurs when the Orientation property value changes, indicating a change in the layout direction of menu items.
public event EventHandler OrientationChanged
Occurs when the text orientation property value changes, affecting how text is displayed within menu items.
public event EventHandler TextOrientationChanged