Collection::Item

Description

It returns the nIndex'th item of the collection.


It returns the item with the name lpcszName in the collection.

Syntax

_TemplType Item( int nIndex )

_TemplType Item( LPCSTR lpcszName )

Parameters

nIndex
0-offset index of the needed item in the collection.

lpcszName
the name of the desired item.

Return

the item corresponding to the supplied index.


the item corresponding to the supplied name.

Examples

EX1

void    run_Collection_Item_ex1()
{
    // Default constructor creates an unattached Collection object:
    Collection<PageBase>    pgColl;
    
    // Attach to the collection of all the pages in the project:
    pgColl = Project.Pages;

    // Get the first page in the collection:
    PageBase                pg = pgColl.Item(0);
    
    // Display the name of the page:
    out_str(pg.GetName());
}


EX2

// For this example to run, make sure that the project contains
// a worksheet window.
void    run_Collection_Item_ex2()
{
    // Default constructor creates an unattached Collection object:
    Collection<PageBase>    pgColl;
    
    // Attach to the collection of all the pages in the project:
    pgColl = Project.Pages;

    WorksheetPage wksP = Project.WorksheetPages(0);
    if(wksP)
    {
        // Get the worksheet page  in the collection:
        PageBase                pg = pgColl.Item(wksP.GetName());
        
        // Display the name of the page:
        out_str(pg.GetName());
    }
}

Remark

See Also

header to Include

origin.h