1.20.2 Collections
CollectionsThe Collection class provides a template for holding multiple objects of the same type. In Origin C, an instance of a Collection is read-only. You cannot add items to, or delete items from, a collection.
There are a number of Origin C classes that contain data members which are instances of a Collection. For example, the Project class contains a data member named WorksheetPages. The WorksheetPages data member is a collection of all the existing WorksheetPage objects in the project.
The table below lists each of the Origin C Collections, along with the class that contains the collection and the item types in the collection.
Examples
Project, List all Graph PagesList all graph pages in the current project.
foreach(GraphPage gp in Project.GraphPages)
{
out_str(gp.GetName());
}
Project, List all WorkbooksList all worksheet pages in the current project.
foreach(WorksheetPage wksPage in Project.WorksheetPages)
{
out_str(wksPage.GetName());
}
Project, List all MatrixbooksList all matrix pages in the current project.
foreach(MatrixPage matPage in Project.MatrixPages)
{
out_str(matPage.GetName());
}
Graph Layer, List all Data PlotsList all data plots.
GraphLayer gl = Project.ActiveLayer();
foreach(DataPlot dp in gl.DataPlots)
{
string strRange;
dp.GetRangeString(strRange, NTYPE_BOOKSHEET_XY_RANGE);
printf("%d, %s", dp.GetIndex()+1, strRange);
}
|