AddSwitch Method
Description
Adds a switch to the Switch Pane.
Syntax
Public Sub AddSwitch( _
ByVal [Id](#) As Long, _
ByVal [ToolTip](#) As String _
)
Parameters
- Id: Id of the switch.
- ToolTip: Tooltip of the switch.
Remarks
AddSwitch will add a new switch to the Switch Pane.

Notes:
- AddSwitchPane is used to add a Switch Pane to the status bar.
- A switch can be removed by passing the Id of the switch to RemoveSwitch.
- The SwitchPaneClick event can be used to select/check a switch when it is clicked, as well as perform some other action when the appropriate switch has been clicked.
- The Checked property holds the Id of the currently selected switch.
Example
' Code to load images for switches, add a switch pane, and switches
CommandBars.Icons.LoadBitmap App.Path & "\res\StatusBarViewSwitches.png", _
Array(ID_SWITCH_PRINTLAYOUT, ID_SWITCH_FULLSCREENREADING, ID_SWITCH_WEBLAYOUT, ID_SWITCH_OUTLINE, ID_SWITCH_DRAFT), xtpImageNormal
Dim SwitchPane As StatusBarSwitchPane
Set SwitchPane = StatusBar.AddSwitchPane(ID_INDICATOR_VIEWSHORTCUTS)
SwitchPane.AddSwitch ID_SWITCH_PRINTLAYOUT, "Print Layout"
SwitchPane.AddSwitch ID_SWITCH_FULLSCREENREADING, "Full Screen Reading"
SwitchPane.AddSwitch ID_SWITCH_WEBLAYOUT, "Web Layout"
SwitchPane.AddSwitch ID_SWITCH_OUTLINE, "Outline"
SwitchPane.AddSwitch ID_SWITCH_DRAFT, "Draft"
SwitchPane.Checked = ID_SWITCH_PRINTLAYOUT
SwitchPane.Caption = "&View Shortcuts"
Private Sub StatusBar_SwitchPaneClick(ByVal Pane As XtremeCommandBars.StatusBarSwitchPane, ByVal Id As Long)
Pane.Checked = Id
Select Case Id
Case ID_SWITCH_PRINTLAYOUT:
MsgBox "Print Layout Switch Clicked"
Case ID_SWITCH_FULLSCREENREADING:
MsgBox "Full Screen Reading Switch Clicked"
Case ID_SWITCH_WEBLAYOUT:
MsgBox "Web Layout Switch Clicked"
Case ID_SWITCH_OUTLINE:
MsgBox "Outline Switch Clicked"
Case ID_SWITCH_DRAFT:
MsgBox "Draft Switch Clicked"
End Select
End Sub
See Also
- StatusBarSwitchPane Object
- RemoveSwitch Method
- Id Property
- AddSwitchPane Method
- SwitchPaneClick Event
- Checked Property
Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.