Adds an array of integer, long, date, string, double, float, or variant arrays to the
list.
![]() | Type | Description | ||
| Items as Variant | A safe array that control uses to fill with. | |||
| Index as Variant | Only for future use. |
Use the PutItems property when you have a table of elements stored into an array. Use the AddItem method to add a single item to the control. Use the InsertItem method to insert a child item to the control. Use the ItemPosition property to specify the item's position. Use the GetItems method to get the items collection to a safe array. Use the ColumnAutoResize property to specify whether the visible columns should fit the control's client area. Use the ConditionalFormats method to apply formats to a cell or range of cells, and have that formatting change depending on the value of the cell or the value of a formula.
The following VB sample uses the VB Array function to fill the control's items collection:
With ComboBox1
.BeginUpdate
.HeaderVisible = False
.Columns.Add "Column 1"
.PutItems Array(1, 2, "Jhon", Me.Font)
.EndUpdate
End With
The following VB loads an array of strings.
Dim v(2, 2) As String v(0, 0) = "One" v(0, 1) = "Two" v(0, 2) = "Three" v(1, 0) = "One" v(1, 1) = "Two" v(1, 2) = "Three" v(2, 0) = "One" v(2, 1) = "Two" v(2, 2) = "Three" ComboBox1.BeginUpdate ComboBox1.Columns.Add "Column 1" ComboBox1.Columns.Add "Column 2" ComboBox1.Columns.Add "Column 3" ComboBox1.PutItems v ComboBox1.EndUpdate
The following VB sample shows how to load an ADO recordset using PutItems method.
Set rs = CreateObject("ADODB.Recordset")
rs.Open "Orders", "Provider=Microsoft.Jet.OLEDB.3.51;Data Source= D:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB", 3 ' Opens the table using static mode
ComboBox1.BeginUpdate
For Each f In rs.Fields
ComboBox1.Columns.Add f.Name
Next
ComboBox1.PutItems rs.GetRows()
ComboBox1.EndUpdate
The following VB.NET sample adds a column and some items to a drop down list control:
With AxComboBox1
.BeginUpdate()
.ColumnAutoResize = True
.Columns.Add("Column 1")
Dim o() As Object = {1, "Item 2", 3, 4, 5}
.PutItems(o)
.Items.SelectItem(.Items.FindItem("Item 2")) = True
.EndUpdate()
End With