@...GRID
DEFINE GRID 
Creates a Grid control.
  

A control Grid is a container object that displays data in rows and columns, and is similar in appearance to a Browse window.

SYNTAX

Standard Window:

@ <nRow> ,<nCol> GRID <ControlName>
[ ID <
nId> ]
[ OF | PARENT | DIALOG <
ParentWindowName> ]
[ WIDTH <
nWidth> ]
[ HEIGHT <
nHeight> ]
[ HEADERS <
acHeaders> ]
[ WIDTHS <
anWidths> ]
[ ITEMS <
acItems> ]
[ VALUE <
nValue> ]
[ FONT <
cFontName> SIZE <nFontSize> ]
[ BOLD ] [ ITALIC ] [ UNDERLINE ] [ STRIKEOUT ]
[ TOOLTIP <
cToolTipText> ]
[ BACKCOLOR <
anBackColor> ]
[ FONTCOLOR <
anFontColor> ]
[ DYNAMICBACKCOLOR <
anDynamicBackColor> ]
[ DYNAMICFORECOLOR <
anDynamicForeColor> ]
[ ON GOTFOCUS <
OnGotFocusProcedure> | <bBlock> ]
[ ON CHANGE <
OnChangeProcedure> | <bBlock> ]
[ ON LOSTFOCUS <
OnLostFocusProcedure> | <bBlock> ]
[ [ ON DBLCLICK <
OnDblClickProcedure> | <bBlock> ]  |  [ EDIT ] ]
[ ON HEADCLICK <
aOnHeadClickProcedure> | <abBlock> ]
[ ON CHECKBOXCLICKED C
heckBoxesRefresh() ]
[ INPLACE <
EditControls> ]
[ CELLED | CELLNAVIGATION ]
[ COLUMNCONTROLS {
aControlDef1, aControlDef2,...aControlDefN } ]
[ COLUMNVALID <ColumnValid> ]
[ COLUMNWHEN <
ColumnWhen> ]
[ COLUMNWIDTHLIMITS <
aWidthLimits ]
[ VALIDMESSAGES <
acValidationMessages> ]
[ VIRTUAL ]
[ ITEMCOUNT <
nItemCount> ]
[ ON QUERYDATA <
OnQueryDataProcedure> | <bBlock> ]
[ MULTISELECT ]
[ NOLINES ]
[ NOHEADERS ]
[ NOSORTHEADERS]
[ IMAGE <
acImageNames> ]
[ JUSTIFY <
anJustifyValue> ]
[ HELPID <
nHelpId> ]
[ BREAK ]
[ COLUMNSORT <
columnsort> ]
[ HEADERIMAGE <
aImageHeader> ]
[ NOTABSTOP ]
[ CHECKBOXES ]
[ LOCKCOLUMNS <L
ockColumns> ]
[ PAINTDOUBLEBUFFER> ]
[ ON INIT <
bInit> ]

Dialog Window:

REDEFINE GRID <ControlName>
ID <
nId>
[ OF | PARENT | DIALOG <
ParentWindowName> ]
[ HEADERS <
acHeaders>]
[ WIDTHS <
anWidths> ]
[ ITEMS <
acItems> ]
[ VALUE <
nValue> ]
[ FONT <
cFontname> SIZE <nFontsize> ]
[ BOLD ] [ ITALIC ] [ UNDERLINE ] [ STRIKEOUT ]
[ TOOLTIP <
cToolTipText> ]
[ BACKCOLOR <
anBackColor> ]
[ FONTCOLOR <
anFontColor> ]
[ DYNAMICBACKCOLOR <
anDynamicBackColor> ]
[ DYNAMICFORECOLOR <
anDynamicForeColor> ]
[ ON GOTFOCUS <
OnGotFocusProcedure> | <bBlock> ]
[ ON CHANGE <
OnChangeProcedure> | <bBlock> ]
[ ON LOSTFOCUS <
OnLostFocusProcedure> | <bBlock> ]
[ [ ON DBLCLICK <
OnDblClickProcedure> | <bBlock> ] | [ EDIT ] ]
[ ON HEADCLICK <
aOnHeadClickProcedure> | <abBlock> ]
[ ON CHECKBOXCLICKED C
heckBoxesRefresh() ]
[ INPLACE <
EditControls> ]
[ CELLED | CELLNAVIGATION ]
[ COLUMNVALID <
ColumnValid> ]
[ COLUMNCONTROLS {
aControlDef1, aControlDef2,...aControlDefN } ]
[ COLUMNWHEN <
ColumnWhen> ]
[ COLUMNWIDTHLIMITS <
aWidthLimits ]
[ VALIDMESSAGES <a
cValidationMessages> ]
[ VIRTUAL ]
[ ITEMCOUNT <
nItemCount> ]
[ ON QUERYDATA <
OnQueryDataProcedure> | <bBlock> ]
[ MULTISELECT ]
[ NOLINES ]
[ NOHEADERS ]
[ NOSORTHEADERS ]
[ IMAGE <
acImageNames> ]
[ JUSTIFY <
anJustifyValue> ]
[ HELPID <
nHelpId> ]
[ BREAK ]
[ COLUMNSORT <
columnsort> ]
[ HEADERIMAGE <
aImageHeader> ]
[ NOTABSTOP ]
[ CHECKBOXES ]
[ LOCKCOLUMNS <L
ockColumns> ]
[ PAINTDOUBLEBUFFER> ]
[ ON INIT <
bInit> ]

SPLITBOX VERSION

GRID <ControlName>
[ OF | PARENT <
ParentWindowName> ]
[ WIDTH <
nWidth> ]
[ HEIGHT <
nHeight> ]
[ HEADERS <
acHeaders>]
[ WIDTHS <
anWidths> ]
[ ITEMS <
acItems> ]
[ VALUE <
nValue> ]
[ FONT <
cFontName> SIZE <nFontSize> ]
[ BOLD ] [ ITALIC ] [ UNDERLINE ] [ STRIKEOUT ]
[ TOOLTIP <
cToolTipText> ]
[ BACKCOLOR <
anBackColor> ]
[ FONTCOLOR <
anFontColor> ]
[ DYNAMICBACKCOLOR <
aDynamicBackColor> ]
[ DYNAMICFORECOLOR <
aDynamicForeColor> ]
[ ON GOTFOCUS <
OnGotFocusProcedure> | <bBlock> ]
[ ON CHANGE <
OnChangeProcedure> | <bBlock> ]
[ ON LOSTFOCUS <
OnLostFocusProcedure> | <bBlock> ]
[ [ ON DBLCLICK <
OnDblClickProcedure> | <bBlock> ]  |  [ EDIT ] ]
[ ON HEADCLICK <
aOnHeadClickProcedure> | <abBlock> ]
[ ON CHECKBOXCLICKED C
heckBoxesRefresh() ]
[ INPLACE <
EditControls> ]
[ CELLED | CELLNAVIGATION ]
[ COLUMNVALID <
ColumnValid> ]
[ COLUMNCONTROLS {
aControlDef1, aControlDef2,...aControlDefN } ]
[ COLUMNWHEN <ColumnWhen> ]
[ COLUMNWIDTHLIMITS <
aWidthLimits ]
[ VALIDMESSAGES <a
cValidationMessages> ]
[ VIRTUAL ]
[ ITEMCOUNT <
nItemCount> ]
[ ON QUERYDATA <
OnQueryDataProcedure> | <bBlock> ]
[ MULTISELECT ]
[ NOLINES ]
[ NOHEADERS ]
[ NOSORTHEADERS ]
[ IMAGE <
acImageNames> ]
[ JUSTIFY <
anJustifyValue> ]
[ HELPID <
nHelpId> ]
[ BREAK ]
[ COLUMNSORT <
columnsort> ]
[ HEADERIMAGE <
aImageHeader> ]
[ NOTABSTOP
]
[ CHECKBOXES ]
[ LOCKCOLUMNS <
LockColumns> ]
[ PAINTDOUBLEBUFFER> ]
[ ON INIT <
bInit> ]

Alternate Syntax:

DEFINE GRID <ControlName>

[ ID <nId> ]
[ PARENT <
ParentWindowName> ]
COL <
nCol>
ROW <
nRow>
[ WIDTH <
nWidth> ]
[ HEIGHT <
nHeight> ]
[ HEADERS <
acHeaders>]
[ WIDTHS <
anWidths> ]
[ ITEMS <
acItems> ]
[ VALUE <
nValue> ]
[ FONTNAME <
cFontName> ]
[ FONTSIZE <
nFontSize> ]
[ FONTBOLD < .T. | .F.> ]
[ FONTITALIC < .T. | .F.> ]
[ FONTUNDERLINE < .T. | .F.> ]
[ FONTSTRIKEOUT < .T. | .F.> ]
[ TOOLTIP <
cToolTipText> ]
[ BACKCOLOR <
anBackColor> ]
[ FONTCOLOR <
anFontColor> ]
[ DYNAMICBACKCOLOR <
anDynamicBackColor> ]
[ DYNAMICFORECOLOR <
anDynamicForeColor> ]
[ ONGOTFOCUS <
OnGotFocusProcedure> | <bBlock> ]
[ ONCHANGE <
OnChangeProcedure> | <bBlock> ]
[ ONLOSTFOCUS <
OnLostFocusProcedure> | <bBlock> ]
[ [ ONDBLCLICK <
OnDblClickProcedure> | <bBlock> ]
    | [ ALLOWEDIT < .T. | .F.>  ]  ]
[ ONHEADCLICK <
aOnHeadClickProcedure> | <abBlock> ]
[ ONCHECKBOXCLICKED C
heckBoxesRefresh() ]
[ INPLACEEDIT <
EditControls> ]
[ CELLED | CELLNAVIGATION < .T. | .F.> ]
[ COLUMNCONTROLS {
aControlDef1, aControlDef2,...aControlDefN } ]
[ COLUMNVALID <ColumnValid> ]
[ COLUMNWHEN <
ColumnWhen> ]
[ COLUMNWIDTHLIMITS <
aWidthLimits ]
[ VALIDMESSAGES <a
cValidationMessages> ]
[ VIRTUAL < .T. | .F.> ]
[ ITEMCOUNT <
nItemCount> ]
[ ON QUERYDATA <
OnQueryDataProcedure> | <bBlock> ]
[ MULTISELECT < .T. | .F.> ]
[ NOLINES < .T. | .F.> ]
[ SHOWHEADERS < .T. | .F.> ]
[ NOSORTHEADERS < .T. | .F.> ]
[ IMAGE <
acImageNames> ]
[ JUSTIFY <
anJustifyValue> ]
[ HELPID <
nHelpId> ]
[ BREAK < .T. | .F.> ]
[ COLUMNSORT <
columnsort> ]
[ HEADERIMAGE <
aImageHeader> ]
[ NOTABSTOP < .T. | .F.> ]
[ CHECKBOXES < .T. | .F.> ]
[ LOCKCOLUMNS <
LockColumns> ]
[ PAINTDOUBLEBUFFER < .T. | .F.> ]
[ ONINIT <
bInit> ]

END GRID

EDIT INPLACE { aControlDef1 , aControlDef2 , ... , aControlDefN }

Control Definition Array:

TEXTBOX {
cControlType , cDataType , cInputMask , cFormat }

cControlType = 'TEXTBOX' (Required)
cDataType = 'CHARACTER' , 'NUMERIC' , 'DATE' (Required)
cInputMask = cInputMask (Optional)
cFormat = cFormat (Optional)

DATEPICKER {
cControlType , cControlStyle }

cControlType = 'DATEPICKER' (Required)
cControlStyle = 'DROPDOWN' , 'UPDOWN' (Required)

COMBOBOX {
cControlType , acItems }

cControlType 'COMBOBOX' (Required)
acItems (Required)

SPINNER {
cControlType , nRangeMin , nRangeMax }

cControlType 'SPINNER' (Required)
nRangeMin (Required)
nRangeMax (Required)

CHECKBOX {
cControlType , cCheckedLabel , cUnCheckedLabel }

cControlType 'CHECKBOX' (Required)
cCheckedLabel (Required)
cUnCheckedLabel (Required)

DYNAMIC {
cControlType , bCodeBlock }

cControlType = 'DYNAMIC' (Required)
bCodeBlock = CodeBlock that return array with normal type control (Required)
                  to CodeBlock is passed two params - row and column indexes.

Data type for each column will depend control specified.

NUMERIC TEXTBOX : NUMERIC
DATE TEXTBOX : DATE
CHARACTER TEXTBOX : CHARACTER
SPINNER : NUMERIC
COMBOBOX : NUMERIC
CHECKBOX : LOGICAL

Remarks

If MULTISELECT clause is used VALUE must be a numeric array, containing the index position of selected items.

If EDIT clause is used, by doubleclicking an item, will open an editing window allowing to change the item content.

EDIT and MULTISELECT clauses can't be used simultaneously.

The leftmost column in a grid control must be left aligned.

When used in control definition, Header property must be loaded with a character array containing as elements as control columns.

When AddColumn / DeleteColumn methods are used, all items in grid (if any) will be lost.

If COLUMNSORT <aSort> clause is used, the array aSort may have the following values for each column:
            0 - no sorting;
            1 - ascending sort;
            2 - descending sort.

DESCRIPTION:
nRow, nCol
Position in the area of ??the window in pixels.
nWidth, nHeight
The desired size of the Grid Control in pixels.
nId
The ID identifier this Control in Dialog Window
ControlName
A reference to the Grid Control
ParentWindowName
A reference to the Parent Window.
nHelpID
The help topic identifier for this Control
acHeaders
A list of text expressions for headers of each column
anWidths
A list of sizes for each column in pixels
acItems
A list of data  ie: Array( nRow, nColumn )
nValue
 
cFontName, nFontSize
A reference to the Font and size the Font.
cToolTipText
Specifies the text for the ToolTip
anBackColor
A list of Background color for text
anFontColor
A list of Foreground color for text
anDynamicBackColor
A list of codeblock returning a Background RGB array for each column
anDynamicForeColor
A list of codeblock returning a Foreground RGB array for each column
OnGotFocusProcedure
An action to be performed when Grid is focused.
OnChangeProcedure
An action to be performed when selecting a new row.
OnLostFocusProcedure
An action to be performed when Browse lost focused.
OnDblClickProcedure
An action to be performed when DblClick a Browse row.
aOnHeadClickProcedure
A list of actions to be executed when a certain column header is clicked with the mouse.
CheckBoxesRefresh
?
{aControlDef1, aControlDef2,...
aControlDefN }
?
ColumnValid
A list of Valid codeblock for each column
ColumnWhen
A list of When codeblock for each column
acValidationMessages
A list of associated messages of fields displayed when editable Field loses its focus and is not valid.
nItemCount
Specifies the number of items in the Grid
OnQueryDataProcedure
?
acImageNames
A list of Image for the 1st Column using an IndexValue
anJustifyValue
A list of Justification value for each column (see Justify table below)
aHeaderImage
A list of Image for the header of each column
 
 
CELLED | CELLNAVIGATION
Specifies that we want to move in the grid in a Cell by Cell mode (Similar to an excel speadsheet)
VIRTUAL
Specifies that we are using Virtual Grid
MULTISELECT
Specifies that we can select multiple items in the Grid
NOLINES
Specifies that we do not want lines between Grid Rows
NOHEADERS
Specifies that we do not want to show column headers
NOSORTHEADERS
Specifies that we do not want to SORT headers
BREAK
?
NOTABSTOP
Stop the control to receive focus and participate in the tabbing sequence
CHECKBOXES
Specifies that we want to add a CheckBox as the first column of the Grid
LOCKCOLUMNS
Specifies to lock (Freeze) column(s) in the grid they will stay visible when scrolling the grid
PAINTDOUBLEBUFFER
?


REMARKS:

·     acImageNames is an array of image to use in the first column of a grid refer to an image by it's Index Position see demo \Samples\Basic\Grid_6

ie : IMAGE { "GreenDot.bmp", "YellowDot.bmp", "RedDot.bmp" }
      ITEMS  { { 1, "Green dot" }, { 2, "Yellow dot" }, { 3, "Red dot" }, { 2, "Yellow dot" } }


    JUSTIFY TABLE: (see \include\i_grid.ch)

#DEFINE Value
Value (Numeric)
 
 
GRID_JTFY_LEFT
0
GRID_JTFY_RIGHT
1
GRID_JTFY_CENTER
2
GRID_JTFY_JUSTIFYMASK
3


PROPERTIES:

·   Value
Set / Gets Grid value - selected record number
·   Enabled
Set / Gets enabled state of a Grid control
·   Visible          
Set / Gets visible a Grid control.
·   Row
Set / Gets row position of a Grid control.
·   Col   
Set / Gets column position of a Grid control.
·   Width
Set / Gets width of a Grid control.
·   Height
Set / Gets height of a Grid control.
·   Header (nColumnIndex)
Set / Get header text in a Grid control.
·   HeaderImage(nColumnNumber)
Set / Gets header image in a Grid control.
Set / Gets column display position in a browse control
·   FontName
Set / Gets Grid control's font name.
·   FontSize
Set / Gets Grid control's font size.
·   FontBold
Set / Gets Grid control's font bold property
·   FontItalic
Set / Gets Grid control's font italic property
Set / Gets Grid control's font underline property
Set / Gets Grid control's font strikeout property
·   ToolTip
Set / Gets Grid control's tooltip text.
·   BackColor
Set / Gets the background color for text within the control
·   FontColor
Set / Gets the foreground color for text within the control
·   Cargo
Set / Gets user property 'Cargo' for Grid control
·   Item ( nItemIndex )
Set / Get item text in a Grid control.
·   Cell( nRow , nCol )
Set / Get cell value in Grid control.
·   ItemCount (R)
Get item count in a Grid control.
·   ColumnCount(R)
Get item count in a Grid control.
·   Name (R)
Retrieves the name of a Grid control.
·   Parent(D)
Set the name as character identifier of the parent window.
·   HelpId (D)
Set the numeric help topic identifier of the control.
·   Widths(D)
Set an array containing the sizes for each column of the Grid
·   Virtual(D)
Specifies whether a Grid control allow virtual rows
·   ValidMessages(D)
Character array (one element per column) with messages to show when valid procedure returns .F.
·   MultiSelect(D)
Specifies whether multiple selection is allowed in Grid controls
·   NoLines(D)
Specifies whether lines are shown in a Grid control
·   Image(D)
Specifies a character array containing image filenames or resource names to be used with Grid control
·   Justify(D)
Numeric array (one element for each column) containing justification constants for  Grid controls
·   AllowEdit(D)
Specifies whether records can be edited from a table within a Grid control (Available at control definition)
·   ColumnControls(D)
Specifies controls to be used for each column in a Grid Control
·   ColumnValid(D)
Codeblock array (one element per column) that is evaluated after field editing for Grid control
·   ColumnWhen(D)
Codeblock array (one element per column) that is evaluated prior to field editing for Grid control
Numeric array ( { nMinWidth, nMaxWidth } or NIL.) for an each column
·   ShowHeaders(D)
Sets a value that indicates whether the header is displayed in the Grid control.
Dynamically Set The Background Color for a Grid Cell
Dynamically Set The Foreground Color for a Grid Cell
Dynamically Set The Background Color for a Grid Header
Dynamically Set The Foreground Color for a Grid Header
Dynamically Set The Font a Grid Header
·   Break(D)
Control passes to the statement that follows the terminated statement.
·   NoTabStop(D)
Sets whether an element behavior can't receive focus and participate in the tabbing sequence
·           ColumnJustify( nColIndex)
Set / Get a justify index in a Grid control.
·           ColumnControl( nColIndex
Set / Get a control in a Grid control.
·           ColumnValid( nColIndex )
Set / Get a valid in a Grid control.
·           ColumnWhen( nColIndex )
Set / Get a when in a Grid control.
· ColumnValidmessage(nColIndex)
Set / Get a Validmessage in a Grid control

D: Available at control definition only
R: Read-Only

Properties Available For OnQueryData Procedure

·     This.QueryData
·     This.QueryRowIndex
·     This.QueryColIndex

Properties Available For OnDblClick Procedure

This.CellRowIndex
This.CellColIndex
This.CellRow
This.CellCol
This.CellWidth
This.CellHeight
This.CellValue

- Note: These properties are not available when OnDblClick procedure
      is fired by <Enter> key pressing.
- Grid controls supports now the code-blocks with an input Value as parameter in the VALIDMESSAGES array


EVENTS:

·   OnGotFocus
Action to be performed when getting the focus
·   OnChange
Action to be performed when generic changing of the control
Action to be performed when losing the focus.
·   OnDblClick
Action to be performed when Double Left clicking.
A list of actions to be executed when a certain column header is clicked with the mouse
·   OnQueryData
Occurs when a virtual Grid control requires data to display a cell

METHODS:

·   Show
Shows a GUI object
·   Hide
Hides a GUI object
·   SetFocus
Gives the focus to a control.
·   Redraw
Redraw a Control
·   Release
Releases a control from memory
·   AddItem ( acItemText )
Add a new item to a Grid control.
·   DeleteItem( nItemIndex )
Deletes an item from a Grid.control
Deletes all items from a Grid.control
·   AddColumn ( [ nColIndex ] , [ cCaption ] , [ nWidth ] , [ nJustify ] )
Add a new column to a Grid control.
·   DeleteColumn ( nColIndex )
Deletes a column from a Grid control.
·   ColumnAutoFit (nColumn)
Set widths of a column to fit column contents text & column contents.
·   ColumnAutoFitH (nColumn)
Set widths of a column to fit column header text & column contents
Set widths of all columns to fit each column contents  text & column contents.
Set widths of all columns to fit each column header text & column contents.
Update enables for Grid control
Update disables for Grid control
·   SaveAs
Save Control as BitMap file.
·   SetArray
Set array to the Grid control
·   GetArray
Get array to the Grid control

EXAMPLE:

See demos in :
\Samples\Basic\Grid
\Samples\Basic\Grid_1
\Samples\Basic\Grid_2
\Samples\Basic\Grid_3
\Samples\Basic\Grid_4
\Samples\Basic\Grid_5
\Samples\Basic\Grid_6
\Samples\Basic\Grid_7
\Samples\Basic\Grid_8
\Samples\Basic\Grid_9
\Samples\Basic\MAINDEMO_(SYNTAX_I) to _(SYNTAX_IV)
\Samples\Advanced\Grid2HTML