HOW TO

Enable and disable an ArcMap UIComboBoxControl with VBA

Last Published: April 25, 2020

Summary

The UIComboBoxControl has an Enabled event which can be set to True or False.

Procedure



  • This is the general structure used with this Enabled event:

    Code:
    Private Function UIComboBoxControl1_Enabled() As Boolean
    UIComboBoxControl1_Enabled = False
    End Function


  • This example uses a UIButtonControl to trigger enabling of the UIComboBoxControl:

    Code:
    Option Explicit
    Dim bSwitch As Boolean

    Private Sub UIButtonControl1_Click()
    If bSwitch = True Then
    bSwitch = False
    Else
    bSwitch = True
    End If
    End Sub

    Private Function UIComboBoxControl1_Enabled() As Boolean
    UIComboBoxControl1_Enabled = bSwitch
    End Function


  • Document events can also be used to trigger enabling of the UIComboBoxControl:

    Code:
    Private Function MxDocument_NewDocument() As Boolean
    bSwitch = True
    End Function

    Private Function MxDocument_OpenDocument() As Boolean
    bSwitch = False
    End Function
    Private Function UIComboBoxControl1_Enabled() As Boolean
    UIComboBoxControl1_Enabled = bSwitch
    End Function

    Note:
    The variable in this example was named 'bSwitch' since it is a Boolean used to switch the combobox on and off. It can, however, have any name.

Article ID:000002677

Software:
  • ArcMap 8 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic