WinForms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class Bar

    Show / Hide Table of Contents

    Class Bar

    Represents and encapsulates the data required for a tool bar in the XP Menus framework.

    Inheritance
    System.Object
    Bar
    MergedBar
    Implements
    IChangeNotifyingItem
    IBarItemContainer
    IDesignable
    System.ICloneable
    System.Runtime.Serialization.ISerializable
    System.Runtime.Serialization.IDeserializationCallback
    Namespace: Syncfusion.Windows.Forms.Tools.XPMenus
    Assembly: Syncfusion.Tools.Windows.dll
    Syntax
    public class Bar : Component, IChangeNotifyingItem, IBarItemContainer, IDesignable, ICloneable, ISerializable, IDeserializationCallback
    Remarks

    This class represents a tool bar's data structure. This has to be associated with a BarManager instance to be displayed in the associated form's command bar. This class is also used by the XPToolBar class to represent a tool bar.

    Examples

    Take a look at our XPMenus samples under the Tools\Samples\Menus Package folder for usage example.

    Constructors

    Bar()

    Overloaded. Creates a new instance of the Bar.

    Declaration
    public Bar()

    Bar(BarManager)

    Creates a new instance of the Bar class and associates it with a BarManager.

    Declaration
    public Bar(BarManager manager)
    Parameters
    Type Name Description
    BarManager manager

    A BarManager instance.

    Bar(BarManager, Int32[])

    Creates a new instance of the BarManager class and associates it with a BarManager.

    Declaration
    public Bar(BarManager manager, int[] separatorIndices)
    Parameters
    Type Name Description
    BarManager manager

    A BarManager instance.

    System.Int32[] separatorIndices

    An integer array of indices representing the positions where separators should be introduced.

    Bar(BarManager, String)

    Creates a new instance of the BarManager class and associates it with a BarManager.

    Declaration
    public Bar(BarManager manager, string barName)
    Parameters
    Type Name Description
    BarManager manager

    A BarManager instance.

    System.String barName

    The bar's name.

    Bar(BarManager, String, BarStyle, BarItemsDesignTime, Int32[])

    Creates a new instance of the BarManager class and associates it with a BarManager.

    Declaration
    public Bar(BarManager manager, string barName, BarStyle barStyle, BarItemsDesignTime barItemsDesignTime, int[] separatorIndices)
    Parameters
    Type Name Description
    BarManager manager

    A BarManager instance.

    System.String barName

    The bar's name.

    BarStyle barStyle

    The bar's style.

    BarItemsDesignTime barItemsDesignTime

    A list of BarItems.

    System.Int32[] separatorIndices

    A list of indices representing the separator positions.

    Bar(SerializationInfo, StreamingContext)

    Declaration
    protected Bar(SerializationInfo info, StreamingContext context)
    Parameters
    Type Name Description
    System.Runtime.Serialization.SerializationInfo info
    System.Runtime.Serialization.StreamingContext context

    Properties

    AllowCustomizing

    Indicates whether the toolbar items can be dragged out and into this bar by the user.

    Declaration
    public virtual bool AllowCustomizing { get; set; }
    Property Value
    Type Description
    System.Boolean

    True to allow user customizing; false otherwise. Default is true.

    Remarks

    Changing this property's value will fire the PropertyChanged event.

    AllowHiding

    Indicates whether this toolbar can be hidden by the user during runtime.

    Declaration
    public virtual bool AllowHiding { get; set; }
    Property Value
    Type Description
    System.Boolean

    True to allow user hiding; false otherwise. Default is true.

    Remarks

    Changing this property's value will fire the PropertyChanged event.

    AllowItemsReorderOnShrunk

    Indicates whether the bar items in this toolbar will be reordered when the toolbar is shrunk to show more bar items.

    Declaration
    public virtual bool AllowItemsReorderOnShrunk { get; set; }
    Property Value
    Type Description
    System.Boolean

    True to allow reordering; false otherwise. Default is true.

    Remarks

    Changing this property's value will fire the PropertyChanged event.

    AllowResizing

    Gets or sets allow resize bar in floating mode.

    Declaration
    public bool AllowResizing { get; set; }
    Property Value
    Type Description
    System.Boolean

    BarName

    Gets or sets the bar's name.

    Declaration
    public virtual string BarName { get; set; }
    Property Value
    Type Description
    System.String

    The bar's name.

    Remarks

    This will appear as the caption when Caption is empty.

    The names of these different bars within the manager should be unique.

    Changing this property's value will throw the PropertyChanged event.

    BarStyle

    Gets or sets the bar's style.

    Declaration
    public virtual BarStyle BarStyle { get; set; }
    Property Value
    Type Description
    BarStyle

    One of the BarStyle values.

    Remarks

    The BarStyle will be used only when this bar is associated with a BarManager.

    Changing this property's value will throw the PropertyChanged event.

    Caption

    Gets or sets user friendly bar's caption string, which appears when the tool bar floats and in the customization dialog.

    Declaration
    public virtual string Caption { get; set; }
    Property Value
    Type Description
    System.String
    Remarks

    This will appear as the caption when the tool bar floats and in the customization dialog as the bar's identity.

    DesignMode

    Declaration
    public bool DesignMode { get; }
    Property Value
    Type Description
    System.Boolean

    Items

    Returns the BarItems list.

    Declaration
    public virtual BarItems Items { get; }
    Property Value
    Type Description
    BarItems

    The BarItems collection.

    Remarks

    You can add, remove and insert BarItems into this collection.

    Changing this property's value will throw the PropertyChanged event.

    Manager

    Gets or sets the BarManager this is associated with, if any.

    Declaration
    public virtual BarManager Manager { get; set; }
    Property Value
    Type Description
    BarManager

    An instance of the BarManager object. Can be null.

    MenuItemMergeOrder

    Gets or sets the merge order for the corresponding menu item in the toolbar list popup menu.

    Declaration
    public virtual int MenuItemMergeOrder { get; set; }
    Property Value
    Type Description
    System.Int32
    Remarks

    The items in the context menu that show up with the list of toolbars when right-clicked in the menu area will be ordered based on this setting.

    SeparatorCount

    Declaration
    public int SeparatorCount { get; }
    Property Value
    Type Description
    System.Int32

    SeparatorIndices

    Advanced property, meant for use by the design-time.

    Declaration
    public VisuallyInheritableIntList SeparatorIndices { get; }
    Property Value
    Type Description
    VisuallyInheritableIntList
    Remarks

    Do not use this property directly.

    UpdatedBarItemPositions

    Advanced property, meant for use by the design-time.

    Declaration
    public IntListDesignTime UpdatedBarItemPositions { get; set; }
    Property Value
    Type Description
    IntListDesignTime
    Remarks

    Do not use this property directly.

    UpdatedSeparatorPositions

    Advanced property, meant for use by the design-time.

    Declaration
    public IntListDesignTime UpdatedSeparatorPositions { get; set; }
    Property Value
    Type Description
    IntListDesignTime
    Remarks

    Do not use this property directly.

    Methods

    BeginGroupAt(BarItem)

    Lets you specify a separator in the Items list. The separator will be just before the specified BarItem.

    Declaration
    public void BeginGroupAt(BarItem barItem)
    Parameters
    Type Name Description
    BarItem barItem

    A BarItem present in the items list.

    ClearSeparators()

    Removes all separators between bar items in the tool bar.

    Declaration
    public void ClearSeparators()

    Clone()

    Creates a clone of this bar instance.

    Declaration
    public object Clone()
    Returns
    Type Description
    System.Object

    An object that has similar properties to this bar.

    Remarks

    Creates a new instance of bar and calls the CopyTo(Bar) method to copy over properties.

    Clone(Boolean)

    Creates a clone of this bar instance.

    Declaration
    public object Clone(bool copyClones)
    Parameters
    Type Name Description
    System.Boolean copyClones

    Indicates whether to copy clones of baritems, which are containing in Bar's collection of BarItems.

    Returns
    Type Description
    System.Object

    An object that has similar properties to this bar.

    Remarks

    Creates a new instance of bar and calls the CopyTo(Bar) method to copy over properties.

    CopyTo(Bar)

    Copies the properties of this bar into the specified bar.

    Declaration
    public void CopyTo(Bar bar)
    Parameters
    Type Name Description
    Bar bar

    The bar where the values should be copied to.

    Remarks

    The items list will be shallow copied.

    CopyTo(Bar, Boolean)

    Copies the properties of this bar into the specified bar.

    Declaration
    public void CopyTo(Bar bar, bool copyClones)
    Parameters
    Type Name Description
    Bar bar

    The bar where the values should be copied to.

    System.Boolean copyClones

    Indicates whether to copy clones of baritems, which are containing in Bar's collection of BarItems.

    Remarks

    The items list will be shallow copied.

    Dispose(Boolean)

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing

    GetObjectData(SerializationInfo, StreamingContext)

    Declaration
    public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
    Parameters
    Type Name Description
    System.Runtime.Serialization.SerializationInfo info
    System.Runtime.Serialization.StreamingContext context

    IsGroupBeginning(BarItem)

    Indicates whether a separator is drawn just before the specified BarItem.

    Declaration
    public bool IsGroupBeginning(BarItem barItem)
    Parameters
    Type Name Description
    BarItem barItem

    A BarItem present in the Items list.

    Returns
    Type Description
    System.Boolean

    True if there is a separator; false if not.

    MergeItems(Bar)

    Merges this Bar with another Bar.

    Declaration
    public virtual void MergeItems(Bar barSrc)
    Parameters
    Type Name Description
    Bar barSrc

    A Bar that specifies the Bar to merge with this one.

    Remarks

    Bar items with the same text value are merged according to their MergeType and MergeOrder properties.

    Menu merging of MDI parent and MDI children is handled automatically when the toolbars and the menu items follow the merge rules.

    You can use this method to manually merge two Bar objects (and their submenu items) into a single Bar. Note that the menu items in the source bar should already be added to the BarManager that contains the destination bar.

    Exceptions
    Type Condition
    System.ArgumentException

    The barSrc cannot be the same as this object.

    OnCaptionChanged()

    Raises the CaptionChanged event.

    Declaration
    protected virtual void OnCaptionChanged()

    OnDrawBackground(PaintEventArgs)

    Declaration
    protected virtual bool OnDrawBackground(PaintEventArgs args)
    Parameters
    Type Name Description
    System.Windows.Forms.PaintEventArgs args
    Returns
    Type Description
    System.Boolean

    OnItemsCollectionChanged(Object, CollectionChangeEventArgs)

    Declaration
    protected virtual void OnItemsCollectionChanged(object sender, CollectionChangeEventArgs args)
    Parameters
    Type Name Description
    System.Object sender
    System.ComponentModel.CollectionChangeEventArgs args

    OnPropertyChanged(SyncfusionPropertyChangedEventArgs)

    Raises the PropertyChanged event.

    Declaration
    protected virtual void OnPropertyChanged(SyncfusionPropertyChangedEventArgs args)
    Parameters
    Type Name Description
    SyncfusionPropertyChangedEventArgs args

    A SyncfusionPropertyChangedEventArgs that contains the event data.

    Remarks

    The OnPropertyChanged method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

    Notes to Inheritors: When overriding OnPropertyChanged in a derived class, be sure to call the base class's OnPropertyChanged method so that registered delegates receive the event.

    RaiseCaptionChanged()

    Raises the CaptionChanged event

    Declaration
    protected void RaiseCaptionChanged()

    RemoveGroupAt(BarItem)

    Removes the separator just before this BarItem.

    Declaration
    public void RemoveGroupAt(BarItem barItem)
    Parameters
    Type Name Description
    BarItem barItem

    A BarItem present in the items list.

    RemoveItem(BarItem)

    Removes a BarItem from the BarItems list.

    Declaration
    public virtual void RemoveItem(BarItem item)
    Parameters
    Type Name Description
    BarItem item

    The BarItem to remove.

    ResetAllowHiding()

    Declaration
    protected void ResetAllowHiding()

    ShouldDrawInactiveItems()

    Declaration
    protected virtual bool ShouldDrawInactiveItems()
    Returns
    Type Description
    System.Boolean

    ShouldDrawVisible(BarItem)

    Declaration
    public virtual bool ShouldDrawVisible(BarItem item)
    Parameters
    Type Name Description
    BarItem item
    Returns
    Type Description
    System.Boolean

    ShouldSerializeAllowHiding()

    Declaration
    protected bool ShouldSerializeAllowHiding()
    Returns
    Type Description
    System.Boolean

    UpdateSeparatorIndices()

    Advanced property, meant for use by the design-time.

    Declaration
    protected virtual void UpdateSeparatorIndices()
    Remarks

    Do not use this property directly.

    Events

    CaptionChanged

    Occurs when the Caption value changes in this object.

    Declaration
    public event TextChangedEventHandler CaptionChanged
    Event Type
    Type Description
    TextChangedEventHandler

    DrawBackground

    Declaration
    public event PaintEventHandler DrawBackground
    Event Type
    Type Description
    System.Windows.Forms.PaintEventHandler

    PropertyChanged

    Occurs when a property's value changes in this object.

    Declaration
    public event SyncfusionPropertyChangedEventHandler PropertyChanged
    Event Type
    Type Description
    SyncfusionPropertyChangedEventHandler
    Remarks

    This event may not be thrown for some of the properties in BarItem. Take a look at the property's documentation to confirm whether this event will be thrown for a property.

    Explicit Interface Implementations

    IDesignable.DesignMode

    Declaration
    bool IDesignable.DesignMode { get; }
    Returns
    Type Description
    System.Boolean

    ICloneable.Clone()

    Declaration
    object ICloneable.Clone()
    Returns
    Type Description
    System.Object

    IDeserializationCallback.OnDeserialization(Object)

    Declaration
    void IDeserializationCallback.OnDeserialization(object sender)
    Parameters
    Type Name Description
    System.Object sender

    Implements

    IChangeNotifyingItem
    IBarItemContainer
    IDesignable
    System.ICloneable
    System.Runtime.Serialization.ISerializable
    System.Runtime.Serialization.IDeserializationCallback

    See Also

    BarManager
    XPToolBar
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved