In This Article

ToolBar Class

Represents a standalone toolbar control.

[ToolboxBitmap(typeof(ToolBar))]
public class ToolBar : UIControl, IUIControl, IUIElement, ILogicalTreeNode, IDisposable, IBarControl, IBarObject, IDpiAwareElement, IOrientedElement, IWeakEventListener
Inheritance:
object MarshalByRefObject Component Control ScrollableControl UIControl object
Implements:
IUIControl IUIElement ILogicalTreeNode IDisposable IBarControl IBarObject IDpiAwareElement IOrientedElement IWeakEventListener

Constructors

ToolBar()

Initializes a new instance of the ToolBar class.

public ToolBar()

Properties

BarManager

Gets or sets the BarManager that is managing the toolbar.

public virtual BarManager BarManager { get; set; }

Property Value

BarManager:

The BarManager that is managing the toolbar.

BodyBounds

Gets the bounds of the toolbar body area that contains the command links.

[Browsable(false)]
public Rectangle BodyBounds { get; }

Property Value

Rectangle:

The bounds of the toolbar body area that contains the command links.

Gets the BarCommandLinkCollection containing the command links for use in the control.

[Browsable(false)]
public BarCommandLinkCollection CommandLinks { get; }

Property Value

BarCommandLinkCollection:

The BarCommandLinkCollection containing the command links for use in the control.

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.

Key

Gets or sets a string-based key that uniquely identifies the toolbar.

public string Key { get; set; }

Property Value

string:

A string-based key that uniquely identifies the toolbar.

Orientation

Gets or sets the orientation of the toolbar.

public Orientation Orientation { get; set; }

Property Value

Orientation:

A Orientation that specifies the orientation.

Renderer

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

public IBarRenderer Renderer { get; set; }

Property Value

IBarRenderer:

The control-specific IBarRenderer used to render the control.

Remarks

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

RendererResolved

Gets the IBarRenderer used to render the control.

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

Property Value

IBarRenderer:

The IBarRenderer used to render the control.

Remarks

This property will return a global renderer if there is no control instance renderer override.

ScreenBounds

Gets the screen bounds of the control.

[Browsable(false)]
public Rectangle ScreenBounds { get; }

Property Value

Rectangle:

A Rectangle specifying the screen bounds of the control.

Methods

ArrangeOverride(Size)

Positions child elements and determines an arrange size.

protected override Size ArrangeOverride(Size finalSize)
Parameter Type Description
finalSize Size

The final area within the parent that this element should use to arrange itself and its children.

Returns

Size:

The actual size used.

Remarks

Element authors should override this method, call Arrange on each visible child element and position each child element. It is required that a parent element calls Arrange on each child or they won't be rendered.

CreateChildren()

Invoked when the collection of child elements is to be created.

protected override IList CreateChildren()

Returns

IList:

The IList that should be assigned to the Children property.

Remarks

By default no child collection is created.

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.

MeasureOverride(Graphics, Size)

Measures the size in layout required for child elements and determines a size for the element itself.

protected override Size MeasureOverride(Graphics g, Size availableSize)
Parameter Type Description
g Graphics

The Graphics object to use for measurement.

availableSize Size

The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.

Returns

Size:

The size that this element determines it needs during layout, based on its calculations of child element sizes.

Remarks

Element authors should override this method, call Measure on each visible child element and determine the total size required.

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.

OnMouseDown(MouseEventArgs)

Raises the MouseDown event.

protected override void OnMouseDown(MouseEventArgs e)
Parameter Type Description
e MouseEventArgs

A MouseEventArgs that contains the event data.

OnMouseLeave(EventArgs)

Raises the OnMouseLeave event.

protected override void OnMouseLeave(EventArgs e)
Parameter Type Description
e EventArgs

An EventArgs that contains the event data.

OnMouseMove(MouseEventArgs)

Raises the OnMouseMove event.

protected override void OnMouseMove(MouseEventArgs e)
Parameter Type Description
e MouseEventArgs

A MouseEventArgs that contains the event data.

OnMouseUp(MouseEventArgs)

Raises the MouseUp event.

protected override void OnMouseUp(MouseEventArgs e)
Parameter Type Description
e MouseEventArgs

A MouseEventArgs that contains the event data.

OnRender(PaintEventArgs)

Renders the element.

protected override void OnRender(PaintEventArgs e)
Parameter Type Description
e PaintEventArgs

A PaintEventArgs that contains the event data.

OnRenderChildElements(PaintEventArgs)

Renders the child elements.

protected override void OnRenderChildElements(PaintEventArgs e)
Parameter Type Description
e PaintEventArgs

A PaintEventArgs that contains the event data.

Remarks

This method should not generally be overridden. The default implementation of this method calls the Render(PaintEventArgs) method on all child elements.

WndProc(ref Message)

Occurs when a message is sent to the control.

protected override void WndProc(ref Message m)
Parameter Type Description
m Message

Information about the message.

Events

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

Inherited Members