Starting from a given column index, find a column with the required designation. The column returned could be the first or last found, dependending on the options, and the search could go to the left or to the right.
int FindColIndex( int nRefCol, int nColDesignation, DWORD dwCntrl = 0 )
the column index if found, otherwise a negative number.
EX1
// Indicate error columns and their associated value columns (to left) void Worksheet_FindColIndex_Ex1() { Worksheet wks; wks.Create("origin", CREATE_VISIBLE); int ii, iCol, iColType; for( ii = 1 ; ii <= 10 ; ii++ ) wks.AddCol(); wks.SetColDesignations("XMYEYEXMYEYE"); // Let's go left to right looking for Error columns for( ii = 0 ; ii < wks.GetNumCols() ; ii++ ) { iColType = wks.Columns(ii).GetType(); if( iColType == OKDATAOBJ_DESIGNATION_ERROR || iColType == OKDATAOBJ_DESIGNATION_X_ERROR) { // Once an error column is found, find first data to the left (no dwCntrl needed) switch(iColType) { case OKDATAOBJ_DESIGNATION_ERROR: // A Y Error column, so find its Y iCol = wks.FindColIndex( ii , OKDATAOBJ_DESIGNATION_Y ); if( iCol < 0 ) printf("No Y column found for YErr column %u\n", ii + 1); else printf("Y is column %u, YErr is column %u\n", iCol + 1, ii + 1); break; case OKDATAOBJ_DESIGNATION_X_ERROR: // An X Error column, so find its X iCol = wks.FindColIndex( ii , OKDATAOBJ_DESIGNATION_X ); if( iCol < 0 ) printf("No X column found for XErr column %u\n", ii + 1); else printf("X is column %u, XErr is column %u\n", iCol + 1, ii + 1); } } } }
Worksheet::SetColDesignations, Column::SetType
origin.h