Customizing Microsoft Office commandbars
with custom controls in VB.NET, C#, C++

Toolbar Controls
for Microsoft® Office

Add-in Express Home > Add-in Express for Office and .NET > Online Guide > Add-in Express components > Insight of Toolbar Controls

ADXCommandBarAdvancedControl

The Toolbar Controls implements the ADXCommandBarAdvancedControl class. In addition to properties common for all command bar controls, ADXCommandBarAdvancedControl provides two special properties related to the Toolbar Controls.

The Control property

The Control property binds its ADXCommandBarAdvancedControl to a non-Office control and can be used at design-time as well as at run-time. To place your non-Office control on your command bar you just select your control in the Control property at design-time, or set the Control property to an instance of your control at run-time:

VB.NET


  Private Sub AddinModule_AddinInitialize( _
      ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles MyBase.AddinInitialize
      BossCheckbox = New System.Windows.Forms.CheckBox
      Me.AdxCommandBarAdvancedControl1.Control = BossCheckbox
   End Sub


The ActiveInstance property

The ActiveInstance property is read-only and returns the instance of the Control that was created for the current context. For example, you can initialize your control for the active Inspector by handling the InspectorActivate event:

VB.NET



   Private Sub adxOutlookEvents_InspectorActivate( _
      ByVal sender As System.Object, ByVal inspector As System.Object,
      ByVal folderName As System.String) _ 
         Handles adxOutlookEvents.InspectorActivate

      Dim ChkBox As System.Windows.Forms.CheckBox = _
         Me.AdxCommandBarAdvancedControl1.ActiveInstance
      If ChkBox IsNot Nothing Then ChkBox.Enabled = False
   End Sub


Please note, the ActiveInstance property is not actual in most cases when you'd like to use it. You can always use any window activate events such as the InspectorActivate event of Outlook and WindowActivate event of Word. The table below shows you the order of event processing by the example of the Outlook Inspector window opened by the user.

1. Outlook fires the built-in NewInspector event. Add-in Express traps it and fires the NewInspector event of ADXOutlookEvents.

ActiveInstance returns NULL.

2. ADXOutlookEvents runs your NewInspector event handlers.

ActiveInstance returns NULL.

3. The Toolbar Controls creates an instance of your control.

ActiveInstance returns NULL.

4. Outlook fires the built-in InspectorActivate event. Add-in Express handles it and fires the InspectorActivate event of ADXOutlookEvents.

ActiveInstance returns NULL.

5. The Toolbar Controls creates an instance of your control for the opened Inspector. ADXOutlookEvents runs your InspectorActivate event handlers.

ActiveInstance returns the instance of your control that was cloned from your original control.













Custom Toolbar Controls <<

>> Application-specific control adapters

Back to Add-in Express for Office and .NET homepage