property Grid.Columns as Columns
Retrieves the control's column collection.

TypeDescription
Columns The control's Columns object.

Use the Columns property to access the Columns collection. Use the Columns collection to add, remove or change 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, InsertControlItem 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 two new columns to the control:

With Grid1
    .Columns.Add "Column 1"
    With .Columns.Add("Column 2")
        With .Editor
            .EditType = CalculatorType
        End With
    End With
End With

The following C++ sample adds two new columns to the control:

#include "Column.h"
#include "Columns.h"
COleVariant vtMissing; V_VT( &vtMissing) = VT_ERROR;
CColumns columns = m_grid.GetColumns();
columns.Add( "Column 1" );
CColumn column( V_DISPATCH( &columns.Add( "Column 2" ) ) );
CEditor editor = column.GetEditor();
editor.SetEditType( 21 /*CalculatorType*/ );

The following VB.NET sample adds two new columns to the control:

With AxGrid1
    .Columns.Add("Column 1")
    Dim c As EXGRIDLib.Column = .Columns.Add("Column 2")
    With c.Editor
        .EditType = EXGRIDLib.EditTypeEnum.CalculatorType
    End With
End With

The following C# sample adds two new columns to the control:

EXGRIDLib.Column column = axGrid1.Columns.Add("Column 1") as EXGRIDLib.Column ;
column = axGrid1.Columns.Add("Column 2") as EXGRIDLib.Column;
column.Editor.EditType = EXGRIDLib.EditTypeEnum.CalculatorType;

The following VFP sample adds two new columns to the control:

with thisform.Grid1
	.Columns.Add("Column 1")
	With .Columns.Add("Column 2")
		with .Editor
			.EditType = 21 && CalculatorType
		endwith
	EndWith
endwith