2.2.4.32.43 OriginObject::SetIndex

Description

Set the index of an object in a collection

Syntax

BOOL SetIndex( int nIndex, BOOL bUndo = TRUE )

Parameters

nIndex
[input] A Zero-based Index
bUndo
[input] Set to TRUE if you wish to support Undo, otherwise FALSE

Return

Returns true if the object's index was set, false if not.

Examples

EX1

// Create a new workbook, add some sheets and re-arrange the order
void OriginObject_SetIndex_Ex1()
{
    WorksheetPage wkPage;
    wkPage.Create();    // Create an empty sheet in a new workbook
    wkPage.AddLayer();    // Add a new sheet
    wkPage.AddLayer();    // Add a new sheet
    Worksheet wksLayer3 = wkPage.Layers(2);    // Attach to the third sheet
    bool bRet = wksLayer3.SetIndex(0);    // Set the third sheet to be first
    ASSERT(bRet);
    int nIndex =  wksLayer3.GetIndex();
    ASSERT(nIndex == 0);    // Verify that that the sheet is now first
}

Remark

Set the index of an object in a collection

See Also

OriginObject::GetIndex

Header to Include

origin.h