method Grid.GetItems (Options as Variant)
Gets the collection of items into a safe array,

TypeDescription
Options as Variant Specifies a long expression as follows:
  • if 0, the result is a two-dimensional array with cell's values. The list includes the collapsed items, and the items are included as they are displayed ( sorted, filtered ). This option exports the values of cells. This option exports the values of the cells ( CellValue property ).
  • if 1, the result the one-dimensional array of handles of items in the control as they are displayed ( sorted, filtered ). The list does not include the collapsed items. For instance, the first element in the array indicates the handle of the first item in the control, which can be different that FirstVisibleItem result, even if the control is vertically scrolled. This option exports the handles of the items. For instance, you can use the ItemToIndex property to get the index of the item based on its handle. 
  • else if other, and the number of columns is 1, the result is a one-dimensional array that includes the items and its child items as they are displayed ( sorted, filtered ). In this case, the array may contains other arrays that specifies the child items. The list includes the collapsed items, and the items are included as they are displayed ( sorted, filtered ). This option exports the values of the cells ( CellValue property )

If missing, the Options parameter is 0. If the control displays no items, the result is an empty object (VT_EMPTY).

ReturnDescription
VariantA safe array that holds the items in the control. If the control has a single column, the GetItems returns a single dimension array (object[]), else The safe array being returned has two dimensions (object[,]). The first dimension holds the collection of columns, and the second holds the cells.
The GetItems method to get a safe array that holds the items in the control. The GetItems method gets the items as they are displayed, sorted and filtered. Also, the GetItems method collect the child items as well, no matter if the parent item is collapsed. Use the PutItems method to load an array to the control. The method returns nothing if the control has no columns or items. Use the Items property to access the items collection. You can use the GetItems(1) method to get the list of handles for the items as they are displayed, sorted and filtered. The GetItems method returns an empty expression ( VT_EMPTY ), if there is no items in the result.

/NET Assembly: 

The following C# sample converts the returned value to a object[] when the control contains a single column:

    object[] Items = (object[])exgrid1.GetItems()

or when the control contains multiple columns, the syntax is as follows:

    object[,] Items = (object[,])exgrid1.GetItems()

The following VB.NET sample converts the returned value to a Object() when the control contains a single column:

    Dim Items As Object() = Exgrid1.GetItems()

or when the control contains multiple columns, the syntax is as follows:

    Dim Items As Object(,) = Exgrid1.GetItems()

/COM version: 

The following VB sample gets the items from a control and put them to the second one:

With Grid2
    .BeginUpdate
        .Columns.Clear
        Dim c As EXGRIDLibCtl.Column
        For Each c In Grid1.Columns
            .Columns.Add c.Caption
        Next
        .PutItems Grid1.GetItems
    .EndUpdate
End With 

The following C++ sample gets the items from a control an put to the second one:

#include "Items.h"
#include "Columns.h"
#include "Column.h"
m_grid2.BeginUpdate();
	CColumns columns = m_grid.GetColumns(), columns2 = m_grid2.GetColumns();
	for ( long i = 0; i < columns.GetCount(); i++ )
		columns2.Add( columns.GetItem( COleVariant( i ) ).GetCaption() );
	COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR;
	COleVariant vtItems = m_grid.GetItems( vtMissing );
	m_grid2.PutItems( &vtItems, vtMissing );
m_grid2.EndUpdate();

The following C# sample gets the items from a control and put them to a second one:

axGrid2.BeginUpdate();
for (int i = 0; i < axGrid1.Columns.Count; i++)
	axGrid2.Columns.Add(axGrid1.Columns[i].Caption);
object vtItems = axGrid1.GetItems("");
axGrid2.PutItems(ref vtItems);
axGrid2.EndUpdate();

The following VB.NET sample gets the items from a control and put them to a second one:

With AxGrid2
    .BeginUpdate()
    Dim j As Integer
    For j = 0 To AxGrid1.Columns.Count - 1
        .Columns.Add(AxGrid1.Columns(j).Caption)
    Next
    Dim vtItems As Object
    vtItems = AxGrid1.GetItems("")
    .PutItems(vtItems)
    .EndUpdate()
End With

The following VFP sample gets the items from a control and put them to a second one:

local i
with thisform.Grid2
	.BeginUpdate()
	for i = 0 to thisform.Grid1.Columns.Count - 1
		.Columns.Add( thisform.Grid1.Columns(i).Caption )
	next
	local array vtItems[1]
	vtItems = thisform.Grid1.GetItems("")
	.PutItems( @vtItems )
	.EndUpdate()
endwith