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. | |||
Parent as Variant | A long expression that specifies the handle of the item where the array is being inserted, or 0 if missing |
The PutItems method loads items from a safe array. The Parent parameter of the PutItems method specifies the handle of the item where the array is being inserted as child items. 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 6 sample loads a flat array to a single column control (and shows as in the following picture ):
With ComboBox1 .BeginUpdate .Columns.Add "Column 1" .PutItems Array("Item 1", "Item 2", "Item 3") .EndUpdate End With
or similar for /NET Assembly version:
With Excombobox1 .BeginUpdate() .Columns.Add("Column 1") .PutItems(New String() {"Item 1", "Item 2", "Item 3"}) .EndUpdate() End With
The following VB 6 sample loads a hierarchy to a single column control (and shows as in the following picture ):
With ComboBox1 .BeginUpdate .LinesAtRoot = exLinesAtRoot .Columns.Add "" .PutItems Array("Root 1", Array("Child 1.1", Array("Sub Child 1.1.1", "Sub Child 1.1.2"), "Child 1.2"), "Root 2", Array("Child 2.1", "Child 2.2")) .EndUpdate End With
or similar for /NET Assembly version:
With Excombobox1 .BeginUpdate() .LinesAtRoot = exontrol.EXCOMBOBOXLib.LinesAtRootEnum.exLinesAtRoot .Columns.Add("") .PutItems(New Object() {"Root 1", New Object() {"Child 1.1", New String() {"Sub Child 1.1.1", "Sub Child 1.1.2"}, "Child 1.2"}, "Root 2", New String() {"Child 2.1", "Child 2.2"}}) .EndUpdate() End With
The following VB 6 sample loads a list of items, in a three columns control ( as shown in the following picture ):
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" With ComboBox1 .BeginUpdate .Columns.Add "Column 1" .Columns.Add "Column 2" .Columns.Add "Column 3" .PutItems v .EndUpdate End With
The following VB 6 sample loads a list of items, in a three columns control ( as shown in the following picture ):
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" With ComboBox1 .BeginUpdate .Columns.Add "Column 1" .Columns.Add "Column 2" .Columns.Add "Column 3" .Items.AddItem "Root" .PutItems v, .Items.FirstVisibleItem .EndUpdate End With
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