Skybound Rebar

RebarBand.SpecifiedWidth Property

Gets or sets the specified width of the band. The actual width of the band may be different from the specified width when it expands to the full width of the rebar control.

[Visual Basic]
Public Property SpecifiedWidth As Integer
[C#]
public int SpecifiedWidth {get; set;}

Property Value

The initial or adjusted width of the band.

Remarks

Set this property before the band is assigned to a rebar control to specify the initial width of the band.

This property may equal the actual width of the band, but not always: if the band is resized by the user, the value of this property will equal the width band. But if the rebar control itself is resized, (for example, if the rebar is docked and the width of its container form changes), bands may be automatically resized to fit in the available width. In this situation, the value of the SpecifiedWidth property is maintained such that if the control is resized smaller and then larger, the original state of the bands can be restored.

Note to Translators: This property is marked with the LocalizableAttribute. When the Localizable designer property on a form is set to true, the value of this property is persisted in the resource file associated with each culture. You can localize these resource files without modifying the code.

Example

The following example initializes two bands and adds them to a rebar control. The first band is a MenuBar band with two menu buttons. The second band is a ToolBar band with two push buttons.

private void InitializeRebarBands(Rebar rebar)
{
    // create a new menu bar band:
    RebarBand menuBand = new RebarBand(RebarBandType.MenuBar);
    // turn off size grip for menu:
    menuBand.HasSizeGrip = false;
    // set height of menu at 22:
    menuBand.MinimumSize = new Size(0, 22);
    // specify the width as the fulle width of the rebar to force the next band added
    // to be added below:
    menuBand.SpecifiedWidth = rebar.Width;
    
    menuBand.Buttons.AddRange(new RebarButton[] {
        new RebarButton("btnFile", "&File", null, true, RebarButtonType.Menu),
        new RebarButton("btnHelp", "&Help", null, true, RebarButtonType.Menu)
        });
    
    // create a tool bar band:
    RebarBand toolsBand = new RebarBand(RebarBandType.ToolBar, "Tools", null);
    // set height of the buttons at 32:
    toolsBand.MinimumSize = new Size(0, 32);
    // text will be aligned below images:
    toolsBand.TextAlign = RebarTextAlign.Beside;
    
    toolsBand.Buttons.AddRange(new RebarButton[] {
        new RebarButton("btnNew", "New", null, true, RebarButtonType.Push),
        new RebarButton("btnSave", "Save", null, true, RebarButtonType.Push)
        });
    
    // force text to be visible because these button have no Image assigned
    toolsBand.Buttons[0].TextVisible = true;
    toolsBand.Buttons[1].TextVisible = true;
    
    // add bands to rebar
    rebar.Bands.Add(menuBand);
    rebar.Bands.Add(toolsBand);
}
            

See Also

RebarBand Class | Skybound.Rebar Namespace