Retrieves the control's column collection.
Type | Description | |||
Columns | A Columns object that holds the control's columns collection. |
Use the Columns property to access to control columns. Use the Columns collection you can add, remove or change the control columns. Use the Add method to add a new column to the control. Use the Items property to access the control's items collection. Use the AddItem, InsertItem, or PutItems method to add new items to the control. Use the DataSource property to add new columns and items to the control. Adding new items fails if the control has no columns.
The following VB sample adds a column and some items to a drop down list control:
With ComboBox1 .BeginUpdate .ColumnAutoResize = True .Columns.Add "Column 1" .PutItems Array(1, "Item 2", 3, 4, 5) .Items.SelectItem(.Items.FindItem("Item 2")) = True .EndUpdate End With
The following C++ sample adds a column and some items to a drop down list control:
COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR; m_combobox.BeginUpdate(); m_combobox.SetColumnAutoResize( TRUE ); CColumns columns = m_combobox.GetColumns(); columns.Add( "Column 1" ); CItems items = m_combobox.GetItems(); items.AddItem( COleVariant((long)1) ); items.AddItem( COleVariant("Item 2") ); items.AddItem( COleVariant((long)3) ); items.AddItem( COleVariant((long)4) ); items.AddItem( COleVariant((long)5) ); items.SetSelectItem( items.GetFindItem(COleVariant("Item 2"), COleVariant(long(0)), vtMissing ), TRUE ); m_combobox.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
The following C# sample adds a column and some items to a drop down list control:
axComboBox1.BeginUpdate(); axComboBox1.ColumnAutoResize = true; axComboBox1.Columns.Add("Column 1"); axComboBox1.Items.AddItem(1); axComboBox1.Items.AddItem("Item 2"); axComboBox1.Items.AddItem(3); axComboBox1.Items.AddItem(4); axComboBox1.Items.AddItem(5); axComboBox1.Items.set_SelectItem(axComboBox1.Items.get_FindItem("Item 2",null,null), true); axComboBox1.EndUpdate();
The following VFP sample adds a column and some items to a drop down list control:
With thisform.ComboBox1 .BeginUpdate .ColumnAutoResize = .t. .Columns.Add ("Column 1") With .Items .AddItem(1) .AddItem("Item 2") .AddItem(3) .AddItem(4) .AddItem(5) EndWith .EndUpdate EndWith