ComboBox (cbo)

ComboBox - This control allows the user to either select an item from the drop-down list or to enter a different value into the textbox.

To remove scrollbars from appearing set the ColumnWidths to the width of the combobox
In order to have a short combobox or listbox with the dropdown the same width as the text box make the ListWidth property the same value as the width and make the column width the same as the width as well.
The advantage of this control over a listbox is that a value that is not in the list can be entered.
This control is similar to a listbox although a combobox is a drop-down box and it displays only one item at a time.
The user can also enter a value that does not appear in the list.
To only allow the users to select from the available list change the "Style" property to 2
If you do not want the user to select an entry then change the "MatchEntry" property to -1.
If not then you may get an "Invalid Property Value" error
This is very similar to a list box although a drop down list of possibilities is displaying.


Currently selected item

Obtaining the currently selected item in a combo box.

Call Msgbox (cboComboBox1.Value) 

Adding Items

cboComboBox1.AddItem "one" 
Call cboComboBox1.AddItem("two")

Select a value

cboComboBox1.Value = "some text" 

Cycle through the whole list

For icount = 0 To cboComboBox1.ListCount - 1 
   If cboComboBox1.List(icount) = "match" Then
   End If
Next icount

Multiple Columns

cboComboBox1.ColumnCount = 2 
cboComboBox1.ColumnWidths = "40;40"
cboComboBox1.AddItem "one"
cboComboBox1.List(0, 1) = "three"

cboComboBox1.AddItem "two", 1
cboComboBox1.List(1, 1) = "four"

Changing the Style

cboComboBox1.Style = fmStyle.fmStyleDropDownCombo 
cboComboBox1.Style = fmStyle.fmStyleDropDownList

LinkedCell - 2003
ListFillRange - 2003


Properties

AutoSize 
AutoTab 
AutoWordSelect 
BackColor 
BackStyle 
BorderColor 
BorderStyle 
BoundColumn 
CanPaste 
Column 
ColumnCount 
ColumnHeads 
ColumnWidths 
ControlSource 
ControlTipText 
CurTargetX(excluded from Properties window)
CurX(excluded from Properties window)
DragBehaviour 
DropButtonStyle 
Enabled 
EnterFieldBehaviour 
Font 
ForeColor 
HideSelection 
IMEMode 
Left 
LineCount 
ListAllows you to populate a combo box directly from a 1 or 2 dimensional array.
ListCount 
ListIndex 
ListRows 
ListStyle 
ListWidth 
Locked 
MatchEntry 
MatchFound 
MatchRequiredTrue if the value entered in the text portion of a ComboBox must match an entry in the existing list portion of the control. The user can enter non-matching values, but may not leave the control until a matching value is entered.
MaxLength 
MouseIcon 
MousePointer 
RowSourceLinks the control to a range of cells on a worksheet.
SelectionMargin 
SelLengthThe number of characters selected in a text box or the text portion of a combo box.
SelStartIndicates the starting point of selected text, or the insertion point if no text is selected.
SelTextReturns or sets the selected text of a control.
ShowDropButtonWhen 
SpecialEffectSpecifies the visual appearance of an object.
StyleSpecifies how the user can choose or set the control's value. The combo box can either behave as a drop-down combo or as a listbox.
TabIndex 
TabStop 
Text (default)Control must have focus
TextAlign 
TextColumn 
TextLength 
Top 
TopIndex 
ValueReturns the text in the textbox portion of the control which was the last selected value.
Visible 
Width 

Methods

AddItem 
Clear 
Copy 
Cut 
DropDown 
Move 
Paste 
RemoveItem 
SetFocus 
ZOrder 

Events

AfterUpdate 
BeforeDragOver 
BeforeDragOrPaste 
BeforeUpdate 
ChangeOccurs when the user changes the selection or clears the items.
Click 
DblClick 
DropButtonClick 
Enter 
Error 
Exit 
KeyDown 
KeyPress 
KeyUp 
MouseDown 
MouseMove 
MouseUp 

© 2018 Better Solutions Limited. All Rights Reserved. © 2018 Better Solutions Limited TopPrevNext