Implements standard menu bar populated with standard menu items.
For a list of all members of this type, see StandardMenuBar Members.
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
Aspose.Editor.Client.StandardMenuBar
[Visual Basic]Public Class StandardMenuBar
Remarks
This class contains code which is required to properly integrate with EditorControl in order to enable dynamic updates to the menu items.
Application can inherit this class to change default appearance and behavior if required.
Example
Shows how to remove items from the standard menu.
[C#]
// Normally this code is generated by Visual Studio .NET when you drag and drop
// the editor control into your Windows Form, but you can also code it youself.
EditorControl editorControl = new EditorControl();
editorControl.Dock = DockStyle.Fill;
// Get the reference to the standard menubar
StandardMenuBar menu = editorControl.Bars.Menu as StandardMenuBar;
// Remove "New" menu item from "File" submenu
menu.GetItemAt(0).MenuItems.RemoveAt(0);
// Remove submenu "Help"
menu.RemoveItemAt(5);
[Visual Basic]
' Normally this code is generated by Visual Studio .NET when you drag and drop
' the editor control into your Windows Form, but you can also code it youself.
Dim editorControl As New EditorControl()
editorControl.Dock = DockStyle.Fill
' Get the reference to the standard menubar
Dim menu As StandardMenuBar = CType(IIf(TypeOf editorControl.Bars.Menu Is StandardMenuBar, editorControl.Bars.Menu, Nothing), StandardMenuBar)
' Remove "New" menu item from "File" submenu
menu.GetItemAt(0).MenuItems.RemoveAt(0)
' Remove submenu "Help"
menu.RemoveItemAt(5)
Shows how to add items to the standard menu.
[C#]
// Normally this code is generated by Visual Studio .NET when you drag and drop
// the editor control into your Windows Form, but you can also code it youself.
EditorControl editorControl = new EditorControl();
editorControl.Dock = DockStyle.Fill;
// Get the reference to the standard menubar
StandardMenuBar menu = editorControl.Bars.Menu as StandardMenuBar;
// Get references to some of the standard commands
Command cmdBold = editorControl.Commands["Bold"];
Command cmdItalic = editorControl.Commands["Italic"];
// Construct new submenu
MenuItem menuItemCustom = new MenuItem("Custom", new MenuItem[]
{
cmdBold.GetMenuItem(),
cmdItalic.GetMenuItem()
});
// Add new submenu to the end of the standard menu
menu.AddItem(menuItemCustom);
[Visual Basic]
' Normally this code is generated by Visual Studio .NET when you drag and drop
' the editor control into your Windows Form, but you can also code it youself.
Dim editorControl As New EditorControl()
editorControl.Dock = DockStyle.Fill
' Get the reference to the standard menubar
Dim menu As StandardMenuBar = CType(IIf(TypeOf editorControl.Bars.Menu Is StandardMenuBar, editorControl.Bars.Menu, Nothing), StandardMenuBar)
' Get references to some of the standard commands
Dim cmdBold As Command = editorControl.Commands("Bold")
Dim cmdItalic As Command = editorControl.Commands("Italic")
' Construct new submenu
Dim menuItemCustom As New MenuItem("Custom", New MenuItem() { cmdBold.GetMenuItem(), cmdItalic.GetMenuItem() })
' Add new submenu to the end of the standard menu
menu.AddItem(menuItemCustom)Shows how to implement custom command and assign a menu item for it.
[C#]
private void CreateCustomCommand()
{
// Normally this code is generated by Visual Studio .NET when you drag and drop
// the editor control into your Windows Form, but you can also code it youself.
EditorControl editorControl = new EditorControl();
editorControl.Dock = DockStyle.Fill;
// Create new command
Command cmdAllCaps =
editorControl.Commands.Add("AllCaps",
"All &Caps",
"Applies AllCaps to the selection.",
new CommandHandler(CommandAllCaps));
// Add new command to the end of the first submenu in main menu
StandardMenuBar menu = editorControl.Bars.Menu as StandardMenuBar;
menu.GetItemAt(0).MenuItems.Add(cmdAllCaps.GetMenuItem());
}
private void CommandAllCaps(EditorControl editor)
{
editor.Selection.Range.Font.AllCaps = true;
}
[Visual Basic]
Private Sub CreateCustomCommand()
' Normally this code is generated by Visual Studio .NET when you drag and drop
' the editor control into your Windows Form, but you can also code it youself.
Dim editorControl As New EditorControl()
editorControl.Dock = DockStyle.Fill
' Create new command
Dim cmdAllCaps As Command = editorControl.Commands.Add("AllCaps", "All &Caps", "Applies AllCaps to the selection.", New CommandHandler(AddressOf CommandAllCaps))
' Add new command to the end of the first submenu in main menu
Dim menu As StandardMenuBar = CType(IIf(TypeOf editorControl.Bars.Menu Is StandardMenuBar, editorControl.Bars.Menu, Nothing), StandardMenuBar)
menu.GetItemAt(0).MenuItems.Add(cmdAllCaps.GetMenuItem())
End Sub
Private Sub CommandAllCaps(ByVal editor As EditorControl)
editor.Selection.Range.Font.AllCaps = True
End SubRequirements
Namespace: Aspose.Editor.Client
Assembly: Aspose.Editor.Client (in Aspose.Editor.Client.dll)
See Also
StandardMenuBar Members | Aspose.Editor.Client Namespace | CreateMenuBar