property ComboBox.Value as Variant
Specifies the selected value for controls with a single column.

 TypeDescription 
   Variant A Variant expression that indicates the selected value.  
Use the Value property to get or set the selected value, when the control contains a single column. Use the Select property to get or set the selected value when control contains multiple columns. If the control contains multiple columns, the Value property get or set the selected value on the column pointed by SearchColumnIndex property. Use the SelectItem method to select an item given its handle. Use the ItemByIndex property to access an item given its index. The SelectionChanged event is fired when user changes the control's selection. Use the EditText property to retrieve the text inside the control's label.

The following VB samples are equivalents:

With ComboBox1
    .Select(.SearchColumnIndex) = "Child 2"
End With

and

With ComboBox1
    .Value = "Child 2"
End With

The following VB sample selects the "Root" item:

With ComboBox1
    .BeginUpdate
        .HeaderVisible = False
        .ColumnAutoResize = True
        .Columns.Add "Column 1"
        With .Items
            .InsertItem .AddItem("Root"), , "Child"
        End With
        .Value = "Root"
    .EndUpdate
End With

The following C++ sample selects the "Child 2" item:

m_combobox.SetValue( COleVariant( "Child 2" ) );

The following VB.NET sample selects the "Child 2" item:

With AxComboBox1
    .Value = "Child 2"
End With

The following C# sample selects the "Child 2" item:

axComboBox1.Value = "Child 2";

The following VFP sample selects the "Child 2" item:

with thisform.ComboBox1
	.Object.Value = "Child 2"
endwith



Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.