MenuItem
Namespace: Wisej.Web
Assembly: Wisej.Framework (4.2.0.0)
Represents an individual item that is displayed within a MainMenu or ContextMenu.
- C#
- VB.NET
public class MenuItem : Menu, ICommandSource
Public Class MenuItem
Inherits Menu
Implements ICommandSource
Derives from or implements Menu, ICloneable, ICommandSource.
- AutoShowLoader Gets or sets whether the application blocks the browser with a modal mask when this menu item is clicked and until the server is done processing the execution request.
- AllowHtml Gets or sets a value indicating that the control can display HTML in the Text property.
- Checked Gets or sets whether a check mark appears next to the text of the menu item.
The default event is Click.
Constructors
MenuItem()
Initializes a MenuItem with a blank caption.
MenuItem(text)
Initializes a new instance of the MenuItem class with a specified caption for the menu item.
| Name | Type | Description |
|---|---|---|
| text | String | The caption for the menu item. |
MenuItem(text, onClick)
Initializes a new instance of the class with a specified caption and event handler for the Click event of the menu item.
| Name | Type | Description |
|---|---|---|
| text | String | The caption for the menu item. |
| onClick | EventHandler | The EventHandler that handles the Click event for this menu item. |
MenuItem(text, onClick, shortcut)
Initializes a new instance of the class with a specified caption, event handler, and associated shortcut key for the menu item.
| Name | Type | Description |
|---|---|---|
| text | String | The caption for the menu item. |
| onClick | EventHandler | The EventHandler that handles the Click event for this menu item. |
| shortcut | Shortcut | One of the Shortcut values. |
MenuItem(text, items)
Initializes a new instance of the class with a specified caption and an array of submenu items defined for the menu item.
| Name | Type | Description |
|---|---|---|
| text | String | The caption for the menu item. |
| items | MenuItem[] | An array of MenuItem objects that contains the submenu items for this menu item. |
MenuItem(mergeType, mergeOrder, shortcut, text, onClick, onPopup, onSelect, items)
Initializes a new instance of the MenuItem class with a specified caption; defined event-handlers for the Click, Select and Popup events; a shortcut key; a merge type; and order specified for the menu item.
| Name | Type | Description |
|---|---|---|
| mergeType | MenuMerge | One of the MenuMerge values. |
| mergeOrder | Int32 | The relative position that this menu item will take in a merged menu. |
| shortcut | Shortcut | One of the Shortcut values. |
| text | String | The caption for the menu item. |
| onClick | EventHandler | The EventHandler that handles the Click event for this menu item. |
| onPopup | EventHandler | The EventHandler that handles the Popup event for this menu item. |
| onSelect | EventHandler | The EventHandler that handles the Select event for this menu item. |
| items | MenuItem[] | An array of MenuItem objects that contains the submenu items for this menu item. |
Properties
AllowHtml
Boolean: Gets or sets a value indicating that the control can display HTML in the Text property. (Default: False)
AutoShowLoader
Boolean: Gets or sets whether the application blocks the browser with a modal mask when this menu item is clicked and until the server is done processing the execution request. (Default: False)
Value: true to show the loader; otherwise, false. The default is false.
BackColor
Color: Gets or sets the background color of the menu item.
CharacterCasing
CharacterCasing: Gets or sets the case of the text to display to the user. (Default: Normal)
Value: One of the CharacterCasing enumeration values that specifies the character case to apply to the text displayed to the user.
Checked
Boolean: Gets or sets whether a check mark appears next to the text of the menu item. (Default: False)
Value: true if there is a check mark next to the menu item; otherwise, false. The default is false.
Throws:
- ArgumentException The MenuItem is a top-level menu or has children.
Command
ICommand: Gets or sets the ICommand implementation to invoke. (Default: null)
Enabled
Boolean: Gets or sets whether the menu item is enabled. (Default: True)
Value: true if the menu item is enabled; otherwise, false. The default is true.
Font
Font: Gets or sets the font of the menu item.
ForeColor
Color: Gets or sets the text color of the menu item.
Form
Form: Returns the Form that owns the Menu.
Icon
Image: Gets or sets the icon that is displayed by MenuItem.
Value: The Image to display.
IconSource
String: Gets or sets the theme name or URL for the icon to display in the MenuItem.
Value: The theme name or URL for the icon to display in the MenuItem.
Index
Int32: Gets or sets a value indicating the position of the menu item in its parent menu.
Value: The zero-based index representing the position of the menu item in its parent menu.
Throws:
- ArgumentOutOfRangeException The assigned value is less than zero or greater than the item count.
IsParent
Boolean: Returns a value indicating whether the menu item contains child menu items.
Value: true if the menu item contains child menu items; false if the menu is a standalone menu item.
MdiList
Boolean: Gets or sets whether the menu item will be populated with a list of the Multiple Document Interface (MDI) child windows that are displayed within the associated form. (Default: False)
Value: true if a list of the MDI child windows is displayed in this menu item; otherwise, false. The default is false.
MenuID
Int32: Returns the unique identifier for this menu item.
Value: The unique identifier for this menu item.
MergeOrder
Int32: Gets or sets a value indicating the relative position of the menu item when it is merged with another. (Default: 0)
Value: A zero-based index representing the merge order position for this menu item. The default is 0.
MergeType
MenuMerge: Gets or sets a value indicating the behavior of this menu item when its menu is merged with another. (Default: Add)
Value: A MenuMerge value that represents the menu item's merge type.
Parent
Menu: The parent menu that contains this menu item
RadioCheck
Boolean: Gets or sets whether the MenuItem, if checked, displays a radio-button instead of a check mark. (Default: False)
Value: true if a radio-button is to be used instead of a check mark; false if the standard check mark is to be displayed when the menu item is checked. The default is false.
Shortcut
Shortcut: Gets or sets a value indicating the shortcut key associated with the menu item. (Default: None)
Value: One of the Shortcut values. The default is Shortcut.None.
ShowShortcut
Boolean: Gets or sets whether the shortcut key that is associated with the menu item is displayed next to the menu item caption. (Default: True)
Value: true if the shortcut key combination is displayed next to the menu item caption; false if the shortcut key combination is not to be displayed. The default is true.
SizeMode
MenuItemSizeMode: Gets or sets how the menu item is resized when in a MenuBar or MainMenu (Default: Auto)
Value: One of the MenuItemSizeMode values. The default is Auto.
SourceControl
Control: Returns the Control that owns the ContextMenu.
Text
String: Gets or sets a value indicating the text of the menu item. Use "-" to display the menu separator.
Value: The text caption of the menu item.
Visible
Boolean: Gets or sets whether the menu item is visible. (Default: True)
Value: true if the menu item will be made visible on the menu; otherwise, false. The default is true.
Methods
CloneMenu()
Creates a copy of the current MenuItem.
Returns: MenuItem. A MenuItem that represents the duplicated menu item.
CloneMenu(source, includeChildren)
Creates a copy of the specified MenuItem.
| Parameter | Type | Description |
|---|---|---|
| source | MenuItem | The MenuItem that represents the menu item to copy. |
| includeChildren | Boolean | Indicates whether to clone the menu's child items. |
Dispose(disposing)
Disposes of the resources (other than memory) used by the MenuItem.
| Parameter | Type | Description |
|---|---|---|
| disposing | Boolean | true when this method is called by the application rather than a finalizer. |
MergeMenu()
Merges this MenuItem with another MenuItem and returns the resulting merged MenuItem.
Returns: MenuItem. A MenuItem that represents the merged menu item.
OnBackColorChanged(e)
Raises the BackColorChanged event.
OnCheckedChanged(e)
Raises the CheckedChanged event.
OnClick(e)
Raises the Click event.
OnCommandChanged(e)
Raises the CommandChanged event.
OnFontChanged(e)
Raises the FontChanged event.
OnForeColorChanged(e)
Raises the ForeColorChanged event.
OnInitMenuPopup(e)
Raises the Popup event.
OnPopup(e)
Raises the Popup event.
OnSelect(e)
Raises the Select event.
This event fires only if there is an handler attached to it. A simple overload of the On[Event] method in a derived class will not be invoked unless there is at least one handler attached to the event.
OnTextChanged(e)
Raises the TextChanged event.
OnWebEvent(e)
Processes the event from the client.
| Parameter | Type | Description |
|---|---|---|
| e | WisejEventArgs | Event arguments. |
OnWebRender(config)
Renders the client component.
| Parameter | Type | Description |
|---|---|---|
| config | Object | Dynamic configuration object. |
PerformClick()
Generates a Click event for the MenuItem, simulating a click by a user.
PerformPopup()
Raises the Popup event for this menu item, simulating the opening of its list of child menu items.
The browser raises the Popup event when the menu showing the child items of this menu item appears. Use this method to run the same code on the server without showing the menu, for example to populate the MenuItems collection of menu items that create their child items in the Popup event handler.
The event is raised also when the menu item doesn't have child items.
PerformSelect()
Raises the Select event for this menu item.
Update()
Updates the component on the client.
Events
BackColorChanged
EventHandler Occurs when the BackColor property value changes.
CheckedChanged
EventHandler Occurs when the Checked property value changes.
Click
EventHandler Occurs when the menu item is clicked or selected using a shortcut key or access key defined for the menu item.
CommandChanged
EventHandler Occurs when the Command property value changes.
FontChanged
EventHandler Occurs when the Font property value changes.
ForeColorChanged
EventHandler Occurs when the ForeColor property value changes.
Popup
EventHandler Occurs before a menu item's list of menu items is displayed.
Select
EventHandler Occurs when the user places the pointer over a menu item.
This event fires only if there is an handler attached to it. A simple overload of the On[Event] method in a derived class will not be invoked unless there is at least one handler attached to the event.
TextChanged
EventHandler Occurs when the Text property value changes.
Inherited By
| Name | Description |
|---|---|
| CheckedMenuItem | Represents an individual menu item that is displayed within a MainMenu or ContextMenu and always shows a checkbox next to the label. |
| LinkMenuItem | Represents an individual menu item that is displayed within a MainMenu or ContextMenu rendered using the <a> link element to let the browser process the specified HRef URL. |
Implements
| Name | Description |
|---|---|
| IUserData | Provides access to the UserData and Tag properties associated to the component implementing this interface. |
| IBindableComponent | Bindable components implement this interface. |
| ICommandSource | Defines an object that can invoke a Command. |
| IWisejComponent | All wisej components implement this interface. |
| IWisejSerializable | Allows an object to serialize itself. |