property Columns.Count as Long

Returns the number of objects in a collection.

TypeDescription
Long A long expression that counts the Column objects into collection.
The Count property counts the columns in the collection. Use the Columns property to access the control's Columns collection. Use the Item property to access a column by its index or key. Use the Add method to add new columns to the control. Use the Remove method to remove a column. Use the Clear method to clear the columns collection.

The following VB sample enumerates the columns in the control:

For Each c In ComboBox1.Columns
    Debug.Print c.Caption
Next

The following VB sample enumerates the columns in the control:

For i = 0 To ComboBox1.Columns.Count - 1
    Debug.Print ComboBox1.Columns(i).Caption
Next

The following VC sample enumerates the columns in the control:

#include "Columns.h"
#include "Column.h"
CColumns columns = m_combobox.GetColumns();
for ( long i = 0; i < columns.GetCount(); i++ )
{
	CColumn column = columns.GetItem( COleVariant( i ) );
	OutputDebugString( column.GetCaption() );
}

The following VB.NET sample enumerates the columns in the control:

With AxComboBox1.Columns
    Dim i As Integer
    For i = 0 To .Count - 1
        Debug.WriteLine(.Item(i).Caption)
    Next
End With

The following C# sample enumerates the columns in the control:

EXCOMBOBOXLib.Columns columns =axComboBox1.Columns;
for ( int i = 0; i < columns.Count; i++ )
{
	EXCOMBOBOXLib.Column column = columns[i];
	System.Diagnostics.Debug.WriteLine( column.Caption );
}

The following VFP sample enumerates the columns in the control:

with thisform.ComboBox1.Columns
	for i = 0 to .Count - 1
		wait window nowait .Item(i).Caption
	next
endwith