Style Property

Applies To

ComboBox control, MultiPage control, TabStrip control.

Description

For ComboBox, specifies how the user can choose or set the control's value. For MultiPage and TabStrip, identifies the style of the tabs on the control.

Syntax

For ComboBox:

object.Style [= fmStyle]

For MultiPage and TabStrip:

object.Style [= fmTabStyle]

The Style property syntax has these parts:

Part

Description

object

Required. A valid object.

fmStyle

Optional. Specifies how a user sets the value of a ComboBox.

fmTabStyle

Optional. Specifies the tab style in a MultiPage or TabStrip.


Settings

The settings for fmStyle are:

Constant

Value

Description

fmStyleDropDownCombo

0

The ComboBox behaves as a drop-down combo box. The user can type a value in the edit region or select a value from the drop-down list (default).

fmStyleDropDownList

2

The ComboBox behaves as a list box. The user must choose a value from the list.


The settings for fmTabStyle are:

Constant

Value

Description

fmTabStyleTabs

0

Displays tabs on the tab bar (default).

fmTabStyleButtons

1

Displays buttons on the tab bar.

fmTabStyleNone

2

Does not display the tab bar.


Example

The following example uses the Style property to change the effect of typing in the text area of a ComboBox. The user chooses a style by selecting an OptionButton control and then types into the ComboBox to select an item. When Style is fmStyleDropDownList, the user must choose an item from the drop-down list. When Style is fmStyleDropDownCombo, the user can type into the text area to specify an item in the drop-down list.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

  • Two OptionButton controls named OptionButton1 and OptionButton2.
  • A ComboBox named ComboBox1.
    Private Sub OptionButton1_Click()
        ComboBox1.Style = fmStyleDropDownCombo
    End Sub
    
    Private Sub OptionButton2_Click()
        ComboBox1.Style = fmStyleDropDownList
    End Sub
    
    Private Sub UserForm_Initialize()
        Dim i As Integer
    
        For i = 1 To 10
            ComboBox1.AddItem "Choice " & i
        Next i
    
        OptionButton1.Caption = "Select like ComboBox"
        OptionButton1.Value = True
        ComboBox1.Style = fmStyleDropDownCombo
    
        OptionButton2.Caption = "Select like ListBox"
    End Sub
Example

The following example uses the Style property to specify the appearance of the tabs in MultiPage and TabStrip. This example also demonstrates using a Label. The user chooses a style by selecting an OptionButton.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

  • A Label named Label1.
  • Three OptionButton controls named OptionButton1 through OptionButton3.
  • A MultiPage named MultiPage1.
  • A TabStrip named TabStrip1.
  • Any control inside the TabStrip.
  • Any control in each page of the MultiPage.
    Private Sub OptionButton1_Click()
        MultiPage1.Style = fmTabStyleTabs
        TabStrip1.Style = fmTabStyleTabs
    End Sub
    
    Private Sub OptionButton2_Click()
        'Note that the page borders are invisible
        MultiPage1.Style = fmTabStyleButtons
        TabStrip1.Style = fmTabStyleButtons
    End Sub
    
    Private Sub OptionButton3_Click()
        'Note that the page borders are invisible and
        'the page body begins where the tabs normally appear.
        MultiPage1.Style = fmTabStyleNone
        TabStrip1.Style = fmTabStyleNone
    End Sub
    
    Private Sub UserForm_Initialize()
        Label1.Caption = "Page/Tab Style"
        OptionButton1.Caption = "Tabs"
        OptionButton1.Value = True
        MultiPage1.Style = fmTabStyleTabs
        TabStrip1.Style = fmTabStyleTabs
    
        OptionButton2.Caption = "Buttons"
        OptionButton3.Caption = "No Tabs or Buttons"
    End Sub