In This Article

BarManager Class

Provides a manager for controlling bar objects.

[ToolboxBitmap(typeof(BarManager))]
public class BarManager : Component, IDisposable, ICommandTarget, IWeakEventListener
Inheritance:
object MarshalByRefObject Component object
Implements:
IDisposable ICommandTarget IWeakEventListener

Constructors

BarManager()

Initializes a new instance of the BarManager class.

public BarManager()

Remarks

The default constructor initializes all fields to their default values.

BarManager(IContainer)

Initializes a new instance of the BarManager class.

public BarManager(IContainer container)
Parameter Type Description
container IContainer

An IContainer that represents the container for the component.

Properties

ActiveMdiChildForm

Gets the active MDI child Form in the host container control.

[Browsable(false)]
public Form ActiveMdiChildForm { get; }

Property Value

Form:

The active MDI child Form in the host container control.

AutoUpdateCheckGroups

Gets or sets whether all the checkable buttons in a check group auto-update when one of the buttons is clicked.

public bool AutoUpdateCheckGroups { get; set; }

Property Value

bool:

true if all the checkable buttons in a check group auto-update when one of the buttons is clicked; otherwise, false.

Remarks

When this property is set to true, clicks of checkable buttons will automatically call the SetCheckGroupValue(string, IBarCheckableCommand) method.
If this property is set to false, the SetCheckGroupValue(string, IBarCheckableCommand) method must be called manually to update the check group value when a checkable button is clicked.

AutoUpdateChecks

Gets or sets whether to toggle single checkable buttons when they are clicked.

public bool AutoUpdateChecks { get; set; }

Property Value

bool:

true if single checkable buttons should be toggled when they are clicked; otherwise, false.

Remarks

When this property is set to true, clicks of checkable buttons will automatically toggle the checked status if the button is not part of a check group.

BuiltInCustomizeDialogEnabled

Gets or sets whether to automatically display the built-in run-time Customize dialog when dialog-customize mode is entered.

public bool BuiltInCustomizeDialogEnabled { get; set; }

Property Value

bool:

true if the built-in run-time Customize dialog should be displayed when dialog-customize mode is entered; otherwise, false.

Remarks

Set this property to false if you intend on using a custom run-time Customize dialog.

CategoryLocalization

Gets a StringDictionary that can be used to provide UI localizations for category names.

[Browsable(false)]
public StringDictionary CategoryLocalization { get; }

Property Value

StringDictionary:

A StringDictionary that can be used to provide UI localizations for category names.

Remarks

For instance, to display the category File as Localized File in the Customize dialog, add an entry where File is the key and Localized File is the value.

ClipboardChangedNotificationEnabled

Gets or sets whether the manager tracks clipboard changes and fires the ClipboardChanged event.

public bool ClipboardChangedNotificationEnabled { get; set; }

Property Value

bool:

true if the manager tracks clipboard changes and fires the ClipboardChanged event; otherwise, false.

Remarks

Keep this property false if the ClipboardChanged event functionality is not needed.

CommandUpdateEventDelay

Gets or sets the delay, in milliseconds, between when rounds of the CommandUpdate event fires.

public int CommandUpdateEventDelay { get; set; }

Property Value

int:

The delay, in milliseconds, between when rounds of the CommandUpdate event fires.

Commands

Gets a BarCommandCollection containing the commands associated with the manager.

[Browsable(false)]
public BarCommandCollection Commands { get; }

Property Value

BarCommandCollection:

A BarCommandCollection containing the commands associated with the manager.

CustomizeEnabled

Gets or sets whether customization (via a Customize dialog) is enabled.

public bool CustomizeEnabled { get; set; }

Property Value

bool:

true if customization is enabled; otherwise, false.

Remarks

If customization is enabled, a Customize menu item will appear on the run-time context menu and also on the toolbar options menu.

CustomizeMode

Gets or sets the type of customize mode that is active.

[Browsable(false)]
public BarCustomizeMode CustomizeMode { get; set; }

Property Value

BarCustomizeMode:

A BarCustomizeMode that indicates the type of customize mode that is active.

Gets the BarCommandLink that is currently selected if in CustomizeMode.

[Browsable(false)]
public BarCommandLink CustomizeSelectedCommandLink { get; }

Property Value

BarCommandLink:

The BarCommandLink that is currently selected if in CustomizeMode.

DefaultToolBarStyledMenuWrapWidth

Gets or sets the default menu wrap width, in pixels.

public int DefaultToolBarStyledMenuWrapWidth { get; set; }

Property Value

int:

The default menu wrap width, in pixels.

Remarks

This property value is primarily used for menus that have a toolbar style.

DifferentialBarLayoutData

Gets or sets the current differential layout of all the bar objects managed by this BarManager.

[Browsable(false)]
public XmlDocument DifferentialBarLayoutData { get; set; }

Property Value

XmlDocument:

An XmlDocument containing the layout data of the current differential layout.

DockableToolBars

Gets a BarManagerDockableToolBarCollection containing the dockable toolbars associated with the manager.

[Browsable(false)]
public BarManagerDockableToolBarCollection DockableToolBars { get; }

Property Value

BarManagerDockableToolBarCollection:

A BarManagerDockableToolBarCollection containing the dockable toolbars associated with the manager.

DockableToolBarsCanClose

Gets or sets the global setting for whether dockable toolbars can be closed.

public bool DockableToolBarsCanClose { get; set; }

Property Value

bool:

true if dockable toolbars can be closed; otherwise, false.

Remarks

This setting only affects dockable toolbars whose CanClose property is set to DefaultableBoolean.Default. Any other setting on the toolbar instance overrides this global setting.

DockableToolBarsCanDockHostBottom

Gets or sets the global setting for whether dockable toolbars may be docked to the bottom of the host container control.

public bool DockableToolBarsCanDockHostBottom { get; set; }

Property Value

bool:

true if dockable toolbars may be docked to the bottom of the host container control; otherwise, false.

Remarks

This setting only affects dockable toolbars whose CanDockHostBottom property is set to DefaultableBoolean.Default. Any other setting on the toolbar instance overrides this global setting.

DockableToolBarsCanDockHostLeft

Gets or sets the global setting for whether dockable toolbars may be docked to the left of the host container control.

public bool DockableToolBarsCanDockHostLeft { get; set; }

Property Value

bool:

true if dockable toolbars may be docked to the left of the host container control; otherwise, false.

Remarks

This setting only affects dockable toolbars whose CanDockHostLeft property is set to DefaultableBoolean.Default. Any other setting on the toolbar instance overrides this global setting.

DockableToolBarsCanDockHostRight

Gets or sets the global setting for whether dockable toolbars may be docked to the right of the host container control.

public bool DockableToolBarsCanDockHostRight { get; set; }

Property Value

bool:

true if dockable toolbars may be docked to the right of the host container control; otherwise, false.

Remarks

This setting only affects dockable toolbars whose CanDockHostRight property is set to DefaultableBoolean.Default. Any other setting on the toolbar instance overrides this global setting.

DockableToolBarsCanDockHostTop

Gets or sets the global setting for whether dockable toolbars may be docked to the top of the host container control.

public bool DockableToolBarsCanDockHostTop { get; set; }

Property Value

bool:

true if dockable toolbars may be docked to the top of the host container control; otherwise, false.

Remarks

This setting only affects dockable toolbars whose CanDockHostTop property is set to DefaultableBoolean.Default. Any other setting on the toolbar instance overrides this global setting.

DockableToolBarsCanDrag

Gets or sets the global setting for whether dockable toolbars may be dragged to another location.

public bool DockableToolBarsCanDrag { get; set; }

Property Value

bool:

true if dockable toolbars may be dragged to another location; otherwise, false.

Remarks

This setting only affects dockable toolbars whose CanDrag property is set to DefaultableBoolean.Default. Any other setting on the toolbar instance overrides this global setting.

DockableToolBarsCanFloat

Gets or sets the global setting for whether dockable toolbars may be contained in a floating window.

public bool DockableToolBarsCanFloat { get; set; }

Property Value

bool:

true if dockable toolbars may be contained in a floating window; otherwise, false.

Remarks

This setting only affects dockable toolbars whose CanFloat property is set to DefaultableBoolean.Default. Any other setting on the toolbar instance overrides this global setting.

DockableToolBarsHaveOptionsButtons

Gets or sets the global setting for whether dockable toolbars have options buttons.

public bool DockableToolBarsHaveOptionsButtons { get; set; }

Property Value

bool:

true if dockable toolbars have options buttons; otherwise, false.

Remarks

This setting only affects dockable toolbars whose HasOptionsButton property is set to DefaultableBoolean.Default. Any other setting on the toolbar instance overrides this global setting.

DockableToolBarsHideOnApplicationFocusLoss

Gets or sets whether dockable toolbars hide when the application loses focus.

public bool DockableToolBarsHideOnApplicationFocusLoss { get; set; }

Property Value

bool:

true if dockable toolbars hide when the application loses focus; otherwise, false.

ForwardCommandsTo

Gets or sets the ICommandTarget to forward commands to.

[Browsable(false)]
public ICommandTarget ForwardCommandsTo { get; set; }

Property Value

ICommandTarget:

The ICommandTarget to forward commands to.

HostContainerControl

Gets or sets the Control that should be used as the topmost parent for docking.

public Control HostContainerControl { get; set; }

Property Value

Control:

The Control that should be used as the topmost parent for docking.

ImageList

Gets or sets the ImageList used for item images.

public ImageList ImageList { get; set; }

Property Value

ImageList:

An ImageList. The default value is a null reference.

IsRightToLeft

Gets whether the control is using a right-to-left layout.

[Browsable(false)]
public bool IsRightToLeft { get; }

Property Value

bool:

true if the control is using a right-to-left layout; otherwise, false.

KeyboardShortcutsEnabled

Gets or sets whether keyboard shortcuts are enabled.

public bool KeyboardShortcutsEnabled { get; set; }

Property Value

bool:

true if keyboard shortcuts are enabled; otherwise, false.

KeyboardShortcutsVisibleInToolTips

Gets or sets whether keyboard shortcuts should be visible in tooltips.

public bool KeyboardShortcutsVisibleInToolTips { get; set; }

Property Value

bool:

true if keyboard shortcuts should be visible in tooltips; otherwise, false.

MdiChildCloseButtonVisible

Gets or sets whether maximized MDI child windows (in standard MDI mode) display a close button on the menubar.

public bool MdiChildCloseButtonVisible { get; set; }

Property Value

bool:

true if maximized MDI child windows (in standard MDI mode) display a close button on the menubar; otherwise, false.

Remarks

This setting only applies if standard MDI is in use and a child window is maximized.

MdiChildMinimizeButtonVisible

Gets or sets whether maximized MDI child windows (in standard MDI mode) display a minimize button on the menubar.

public bool MdiChildMinimizeButtonVisible { get; set; }

Property Value

bool:

true if maximized MDI child windows (in standard MDI mode) display a minimize button on the menubar; otherwise, false.

Remarks

This setting only applies if standard MDI is in use and a child window is maximized.

MdiChildRestoreButtonVisible

Gets or sets whether maximized MDI child windows (in standard MDI mode) display a restore button on the menubar.

public bool MdiChildRestoreButtonVisible { get; set; }

Property Value

bool:

true if maximized MDI child windows (in standard MDI mode) display a restore button on the menubar; otherwise, false.

Remarks

This setting only applies if standard MDI is in use and a child window is maximized.

MdiChildSystemButtonVisible

Gets or sets whether maximized MDI child windows (in standard MDI mode) display a system button on the menubar.

public bool MdiChildSystemButtonVisible { get; set; }

Property Value

bool:

true if maximized MDI child windows (in standard MDI mode) display a system button on the menubar; otherwise, false.

Remarks

This setting only applies if standard MDI is in use and a child window is maximized.

MenuBar

Gets the MenuBar that is currently the main menu bar, if any.

[Browsable(false)]
public MenuBar MenuBar { get; }

Property Value

MenuBar:

The MenuBar that is currently the main menu bar, if any.

Modes

Gets a BarModeCollection containing the names of the modes in which the manager may be placed.

public BarModeCollection Modes { get; }

Property Value

BarModeCollection:

A BarModeCollection containing the names of the modes in which the manager may be placed.

PopupMenus

Gets a PopupMenuCollection containing the popup menus associated with the manager.

[Browsable(false)]
public PopupMenuCollection PopupMenus { get; }

Property Value

PopupMenuCollection:

A PopupMenuCollection containing the popup menus associated with the manager.

PopupTowardsCenter

Gets or sets whether to display popups from DockableToolBar controls towards the center of the host container control.

public bool PopupTowardsCenter { get; set; }

Property Value

bool:

true if popups should be displayed towards the center of the host container control; otherwise, false.

ProtectedKeys

Gets the KeysCollection containing Keys that should be flagged as protected.

[Browsable(false)]
public KeysCollection ProtectedKeys { get; }

Property Value

KeysCollection:

The KeysCollection containing Keys that should be flagged as protected.

Remarks

Protected Keys cannot be customized by the end-user.

QuickCustomizeEnabled

Gets or sets whether quick customization (started by holding Alt and clicking on a toolbar button) is enabled.

public bool QuickCustomizeEnabled { get; set; }

Property Value

bool:

true if quick customization is enabled; otherwise, false.

Renderer

Gets or sets the control-specific IBarRenderer used to render the bar controls.

public IBarRenderer Renderer { get; set; }

Property Value

IBarRenderer:

The control-specific IBarRenderer used to render the bar controls.

Remarks

If this value is null, then the global renderer will be used instead.

RendererResolved

Gets the IBarRenderer used to render the bar controls.

[Browsable(false)]
public IBarRenderer RendererResolved { get; }

Property Value

IBarRenderer:

The IBarRenderer used to render the bar controls.

Remarks

This property will return a global renderer if there is no control instance renderer override. The registered renderer type with the UIRendererManager for this property is IBarRenderer.

SelectedMode

Gets or sets the name of the mode that the application is currently in.

public string SelectedMode { get; set; }

Property Value

string:

The name of the mode that the application is currently in.

Tag

Gets or sets the object that contains user-defined data about the object.

[TypeConverter(typeof(StringConverter))]
public object Tag { get; set; }

Property Value

object:

An object that contains user-defined data about the control. The default is null.

Remarks

Any type derived from the object class can be assigned to this property.

Methods

Dispose(bool)

Disposes any resources used by the object.

protected override void Dispose(bool disposing)
Parameter Type Description
disposing bool

Whether the object is being disposed.

GetAllCategories()

Returns the unique category names as an array of strings.

public string[] GetAllCategories()

Returns

string[]:

The unique category names as an array of strings.

GetCheckGroupNames()

Returns the unique check group names as an array of strings.

public string[] GetCheckGroupNames()

Returns

string[]:

The unique check group names as an array of strings.

GetCheckGroupValue(string)

Gets the value of a check group.

public IBarCheckableCommand GetCheckGroupValue(string checkGroupName)
Parameter Type Description
checkGroupName string

The name of the check group whose value to retrieve.

Returns

IBarCheckableCommand:

The IBarCheckableCommand that is currently checked within the check group.

GetCustomizableCategories()

Returns the unique category names as an array of strings, for the categories that contain at least one run-time customize command.

public string[] GetCustomizableCategories()

Returns

string[]:

The unique category names as an array of strings, for the categories that contain at least one run-time customize command.

GetTopLevelBarControl(IBarControl)

Returns the top-level IBarControl for the specified IBarControl.

public static IBarControl GetTopLevelBarControl(IBarControl barControl)
Parameter Type Description
barControl IBarControl

The IBarControl to examine.

Returns

IBarControl:

The top-level IBarControl for the specified IBarControl.

IsKeyAChordStart(string, Keys)

Returns whether the specified Keys combination is a chord key start.

public bool IsKeyAChordStart(string mode, Keys key)
Parameter Type Description
mode string

The mode to examine.

key Keys

The Keys combination to examine.

Returns

bool:

true if the specified Keys combination is a chord key start; otherwise, false.

IsKeyStandalone(string, Keys)

Returns whether the specified Keys combination is a chord key start.

public bool IsKeyStandalone(string mode, Keys key)
Parameter Type Description
mode string

The mode to examine.

key Keys

The Keys combination to examine.

Returns

bool:

true if the specified Keys combination is a chord key start; otherwise, false.

IsShortcutProtected(BarKeyboardShortcut)

Returns whether the specified BarKeyboardShortcut is protected.

public bool IsShortcutProtected(BarKeyboardShortcut shortcut)
Parameter Type Description
shortcut BarKeyboardShortcut

The BarKeyboardShortcut to examine.

Returns

bool:

true if the specified BarKeyboardShortcut is protected; otherwise, false.

Remarks

Protected keyboard shortcuts cannot be customized by the end-user.

LoadBarLayoutFromFile(string)

Load bar layout data from a layout data file.

public void LoadBarLayoutFromFile(string path)
Parameter Type Description
path string

Path to the bar layout data file.

Remarks

This method may throw an exception if the file is not found or if the layout data is invalid. If the data contains a Commands section, all bar commands in the Commands collection will be cleared in preparation for the loading of commands in the data.

Merge(IBarControl, IBarControl, bool)

Merges the source IBarControl with a target IBarControl.

public static void Merge(IBarControl sourceBarControl, IBarControl targetBarControl, bool revertAllFirst)
Parameter Type Description
sourceBarControl IBarControl

The source IBarControl.

targetBarControl IBarControl

The target IBarControl.

revertAllFirst bool

Whether to revert any existing merges on the target IBarControl before performing the merge.

OnCommandClick(BarCommandLinkEventArgs)

Raises the CommandClick event.

protected virtual void OnCommandClick(BarCommandLinkEventArgs e)
Parameter Type Description
e BarCommandLinkEventArgs

A BarCommandLinkEventArgs that contains the event data.

OnCommandPopup(BarCommandLinkEventArgs)

Raises the CommandPopup event.

protected virtual void OnCommandPopup(BarCommandLinkEventArgs e)
Parameter Type Description
e BarCommandLinkEventArgs

A BarCommandLinkEventArgs that contains the event data.

OnCommandUpdate(BarCommandLinkEventArgs)

Raises the CommandUpdate event.

protected virtual void OnCommandUpdate(BarCommandLinkEventArgs e)
Parameter Type Description
e BarCommandLinkEventArgs

A BarCommandLinkEventArgs that contains the event data.

OnCustomizeCommandLinkCreated(BarCommandLinkEventArgs)

Raises the CustomizeCommandLinkCreated event.

protected virtual void OnCustomizeCommandLinkCreated(BarCommandLinkEventArgs e)
Parameter Type Description
e BarCommandLinkEventArgs

A BarCommandLinkEventArgs that contains the event data.

OnCustomizeModeChanged(EventArgs)

Raises the CustomizeModeChanged event.

protected virtual void OnCustomizeModeChanged(EventArgs e)
Parameter Type Description
e EventArgs

A EventArgs that contains the event data.

OnCustomizeSelectedCommandLinkChanged(BarCommandLinkEventArgs)

Raises the CustomizeSelectedCommandLinkChanged event.

protected virtual void OnCustomizeSelectedCommandLinkChanged(BarCommandLinkEventArgs e)
Parameter Type Description
e BarCommandLinkEventArgs

A BarCommandLinkEventArgs that contains the event data.

OnKeyTyped(BarKeyTypedEventArgs)

Raises the KeyTyped event.

protected virtual void OnKeyTyped(BarKeyTypedEventArgs e)
Parameter Type Description
e BarKeyTypedEventArgs

A BarKeyTypedEventArgs that contains the event data.

OnMenuTearOff(BarControlEventArgs)

Raises the MenuTearOff event.

protected virtual void OnMenuTearOff(BarControlEventArgs e)
Parameter Type Description
e BarControlEventArgs

A BarControlEventArgs that contains the event data.

OnSelectedModeChanged(EventArgs)

Raises the SelectedModeChanged event.

protected virtual void OnSelectedModeChanged(EventArgs e)
Parameter Type Description
e EventArgs

A EventArgs that contains the event data.

RaiseCommand(Command)

Raises the specified Command.

public virtual bool RaiseCommand(Command command)
Parameter Type Description
command Command

The Command to raise.

Returns

bool:

true if the Command was handled; otherwise, false.

ResetDockableToolBarLayout()

Resets the dockable toolbar layout and the links on each dockable toolbar.

public void ResetDockableToolBarLayout()

Remarks

This method will reset the Position, DockedRow, and DockedColumn properties on each DockableToolBar. It also clears the layout state information and resets the toolbar's links.

This is only useful if you create a custom DockableToolBar-inheriting class that overrides methods such as ResetDockedColumn().

RevertAllMerges(IBarControl)

Reverts any existing merges on the target IBarControl.

public static void RevertAllMerges(IBarControl targetBarControl)
Parameter Type Description
targetBarControl IBarControl

The target IBarControl.

RevertMerge(IBarControl, IBarControl)

Reverts the merge from the source IBarControl on the target IBarControl.

public static void RevertMerge(IBarControl sourceBarControl, IBarControl targetBarControl)
Parameter Type Description
sourceBarControl IBarControl

The source IBarControl.

targetBarControl IBarControl

The target IBarControl.

SaveBarLayoutToFile(string, bool)

Saves the current layout of all the bar objects managed by this BarManager to a layout data file.

public void SaveBarLayoutToFile(string path, bool isComplete)
Parameter Type Description
path string

Path to the bar layout data file.

isComplete bool

Whether to save a complete layout (including commands) or just differential data.

Remarks

The output layout data is stored in XML format. A complete layout should only be used for backup purposes while a differential layout should be used with applications.

SetAsBaselineLayout()

Notifies all elements of the layout that the currently layout is the "baseline" for differential layouts.

public void SetAsBaselineLayout()

Remarks

This method should only be used if you programmatically generate your layout instead of using the designer.

SetCheckGroupValue(string, IBarCheckableCommand)

Sets the value of a check group.

public void SetCheckGroupValue(string checkGroupName, IBarCheckableCommand commandToCheck)
Parameter Type Description
checkGroupName string

The name of the check group whose value to set.

commandToCheck IBarCheckableCommand

The IBarCheckableCommand to check.

Shows the customize Modify Selection menu.

public void ShowCustomizeModifySelectionMenu(Control ownerControl, BarCommandLink commandLink, Rectangle bounds)
Parameter Type Description
ownerControl Control

The owner Control.

commandLink BarCommandLink

The BarCommandLink for which to display the menu.

bounds Rectangle

The screen Rectangle around which to display the menu.

Events

ClipboardChanged

Occurs when the contents of the clipboard are changed.

public event EventHandler ClipboardChanged

Event Type

EventHandler

Remarks

This event will only fire if ClipboardChangedNotificationEnabled is set to true. Use this event to update the state of an Edit.Paste command so that it reflects whether pasting is allowed.

CommandClick

Occurs when a BarCommand is clicked.

public event BarCommandLinkEventHandler CommandClick

Event Type

BarCommandLinkEventHandler

CommandPopup

Occurs when a BarCommand that causes a popup is clicked.

public event BarCommandLinkEventHandler CommandPopup

Event Type

BarCommandLinkEventHandler

CommandUpdate

Occurs when a BarCommand should be updated.

public event BarCommandLinkEventHandler CommandUpdate

Event Type

BarCommandLinkEventHandler

Remarks

If the CommandUpdateEventDelay is greater than 0, a timer fires this event for each command that is on a visible DockableToolBar when the timer expires, allowing for updating of enabled states.

CustomizeCommandLinkCreated

Occurs when a CommandLink is first dropped from the Customize dialog, allowing for initial customization.

public event BarCommandLinkEventHandler CustomizeCommandLinkCreated

Event Type

BarCommandLinkEventHandler

Remarks

Use this event to pre-populate child command links for certain command link types like BarPopupButtonLink.

CustomizeModeChanged

Occurs when the CustomizeMode property is changed, indicating to start or end customize mode.

public event EventHandler CustomizeModeChanged

Event Type

EventHandler

CustomizeSelectedCommandLinkChanged

Occurs when the CustomizeSelectedCommandLink property is changed, while in customize mode.

public event BarCommandLinkEventHandler CustomizeSelectedCommandLinkChanged

Event Type

BarCommandLinkEventHandler

Remarks

Use this event to be notified when the selection changes while in customize mode. This can be used to update the enabled state of a Modify Selection button on the Customize dialog.

KeyTyped

Occurs when a possible shortcut key is typed.

public event BarKeyTypedEventHandler KeyTyped

Event Type

BarKeyTypedEventHandler

MenuTearOff

Occurs when a menu is torn-off to create a dockable toolbar.

public event BarControlEventHandler MenuTearOff

Event Type

BarControlEventHandler

SelectedModeChanged

Occurs after the SelectedMode property is changed.

public event EventHandler SelectedModeChanged

Event Type

EventHandler

Inherited Members