Expert Software Company : News

miercuri, 21 iulie 2010

GetColumnNumber

LPARAMETERS tcCaption

*-- Validate the input parameter
IF EMPTY(tcCaption)
RETURN 0
ENDIF

LOCAL lnColumn, lcCaption, lnRetVal, lnColumnControl, loCurrentColumn, loCurrentControl
* LOCAL/PRIVATE VARIABLE DESCRIPTIONS
* lnColumn - counting variable used to iterate through all
* grid columns
* lcCaption - column header caption for which to search
* lnRetVal - contains the column number with a matching header
* caption
* lnColumnControl - counting variable used to iterate through
* all controls in a column
* loCurrentColumn - object reference to the column object
* currently being searched.
* loCurrentControl - object reference to the column control
* currently being searched.

lcCaption = UPPER(tcCaption)
lnRetVal = 0

*-- Iterate through all columns
FOR lnColumn = 1 TO This.ColumnCount

*-- Create a LOCAL reference to the current column
loCurrentColumn = This.Columns(lnColumn)

*-- Iterate through all column controls,
*-- looking for header objects
FOR lnColumnControl = 1 TO loCurrentColumn.ControlCount

*-- Create a LOCAL reference to current column control
loCurrentControl = loCurrentColumn.Controls(lnColumnControl)

*-- If we found the header object
IF UPPER(loCurrentControl.BaseClass) = "HEADER"

*-- If the caption of the header matches the
*-- specified caption ... we found our column number
IF UPPER(loCurrentControl.Caption) == lcCaption
lnRetVal = lnColumn
EXIT
ENDIF

ENDIF

ENDFOR

*-- lnRetVal will contain the column number IF we have a match
IF lnRetVal > 0
EXIT
ENDIF

ENDFOR

RETURN lnRetVal


* Method: CGrid.GetColumnNumber()
*) Description:
*) Returns a column number when all that is known is the
*) caption of the column's header.
*@ Inputs:
*@ 1. - caption of the column's header
*@ 2. This.ColumnCount - reference to the column object
*@ 3. This.Columns - number of columns in the grid
*@ 4. This.ControlCount - number of controls in the column
*@ 5. This.BaseClass - baseclass of the column
*@ 6. This.Caption - header caption
*@
* Outputs: None
*$ Usage:
*$ .GetColumnNumber()
*% Example:
*% grdCustomer("Customer ID") - returns the column number
*% of the column that contains the Customer ID caption
*% in the Customer grid.
* Returns: NUMERIC - number of the column that has a header
* with the specified text
* 0 - IF no match is found.
* Assumptions: None
* Rules: None
* Constraints:
* Performance: None
* Enviornmental: None
*? Notes: None
* Local Routines: None
*-- Process:
*-- 1. Validate the input parameter
*-- 2. Declare LOCAL variables
*-- 3. FOR all columns in the grid
*-- 4. Create a LOCAL reference to the current column
*-- 5. FOR all controls in the column
*-- 6. Create a LOCAL reference to current column control
*-- 7. IF we found the header object
*-- 8. IF the caption of the header matches the
*-- specified caption ... we found our column
*-- number
*-- EXIT from the control loop
*-- ENDIF
*-- ENDIF
*-- ENDFOR
*-- 9. If a column number is found, EXIT from the loop
*-- 10. ENDFOR
* Change Log:
* CREATED Thursday, 11/02/95 22:41:04 - CTB:

Niciun comentariu:

Trimiteți un comentariu