Locked, DropButtonStyle, ShowDropButtonWhen Properties Example

The following example demonstrates the different symbols that you can specify for a drop-down arrow in a ComboBox or TextBox. In this example, the user chooses a drop-down arrow style from a ComboBox. This example also uses the Locked property. To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

Private Sub ComboBox1_Click()
    ComboBox1.DropButtonStyle = ComboBox1.Value
    TextBox1.DropButtonStyle = ComboBox1.Value
End Sub

Private Sub UserForm_Initialize()
    ComboBox1.ColumnCount = 2
    ComboBox1.BoundColumn = 2
    ComboBox1.TextColumn = 1
    
    ComboBox1.AddItem "Blank Button"
    ComboBox1.List(0, 1) = 0
    ComboBox1.AddItem "Down Arrow"
    ComboBox1.List(1, 1) = 1
    ComboBox1.AddItem "Ellipsis"
    ComboBox1.List(2, 1) = 2
    ComboBox1.AddItem "Underscore"
    ComboBox1.List(3, 1) = 3
    
    ComboBox1.Value = 0
    
    TextBox1.Text = "TextBox1"
    TextBox1.ShowDropButtonWhen = fmShowDropButtonWhenAlways
    TextBox1.Locked = True
    
    Label1.Caption = "TheDropButton also " _
        & "applies to a TextBox."
    Label1.AutoSize = True
    Label1.WordWrap = False
End Sub