@...GRID / DEFINE
GRID
Creates
a grid control
Standard Syntax (xBase
Style):
@ <nRow> ,<nCol>
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 <aBackColor> ]
[ FONTCOLOR <aFontColor> ]
[ DYNAMICBACKCOLOR <aDynamicBackColor> ]
[ DYNAMICFORECOLOR <aDynamicBackColor> ]
[ ON GOTFOCUS <OnGotFocusProcedur> | <bBlock> ]
[ ON CHANGE <OnChangeProcedure> | <bBlock> ]
[ ON LOSTFOCUS <OnGotFocusProcedur> | <bBlock> ]
[ [ ON DBLCLICK <OnDblClickProcedure> | <bBlock> ] |
[ EDIT | ALLOWEDIT ] ]
[ ON SAVE <OnSaveProcedure> | <bBlock> ]
[
COLUMNCONTROLS {aControlDef1,aControlDef2,...aControlDefN}
[ COLUMNVALID {bValid1,bValid2,...bValidN}
[ COLUMNWHEN {bWhen1,bWhen2,...bWhenN}
[ ON HEADCLICK <abBlock> ]
[ VIRTUAL ]
[ ITEMCOUNT <nItemCount> ]
[ ON QUERYDATA <OnQueryDataProcedure> | <bBlock> ]
[ MULTISELECT ]
[ NOLINES ]
[ NOHEADERS ]
[ IMAGE <acImageNames> ]
[ JUSTIFY <anJustifyValue> ]
[ HELPID <nHelpId> ]
[ BREAK ]
[ HEADERIMAGES <acHeaderImages> ]
[ CELLNAVIGATION ]
[ ROWSOURCE <cRowSource>]
[ COLUMNFIELDS <acColumnFields> ]
[ ALLOWAPPEND ]
[ ALLOWDELETE ]
[ DYNAMICDISPLAY <abDynamicDisplay> ]
[ LOCKCOLUMNS <nValue> ]
Alternate Syntax:
DEFINE GRID <ControlName>
PARENT <ParentWindowName>
ROW <nValue>
COL <nValue>
WIDTH <nValue>
HEIGHT <nValue>
FONTNAME <cValue>
FONTSIZE <nValue>
FONTBOLD <lValue>
FONTITALIC <lValue>
FONTUNDERLINE <lValue>
FONTSTRIKEOUT <lValue>
TOOLTIP <cValue>
ONGOTFOCUS <ActionProcedure>
ONLOSTFOCUS <ActionProcedure>
ONSAVE <ActionProcedure>
ONCHANGE
<ActionProcedure>
TABSTOP <lValue>
HELPID <nValue>
VISIBLE <lValue>
ITEMS <caItems>
HEADERS <acHeaders>
WIDTHS <anWidths>
VALUE <nValue>
BACKCOLOR <aBackColor>
FONTCOLOR <aFontColor>
DYNAMICBACKCOLOR <aDynamicBackColor>
DYNAMICFORECOLOR <aDynamicBackColor>
ONDBLCLICK <OnDblClickProcedure>
ALLOWEDIT <lValue>
COLUMNCONTROLS {aControlDef1,aControlDef2,...aControlDefN}
COLUMNVALID {bValid1,bValid2,...bValidN}
COLUMNWHEN {bWhen1,bWhen2,...bWhenN}
ONHEADCLICK <abBlock>
VIRTUAL <lValue>
ITEMCOUNT <nItemCount>
ONQUERYDATA <OnQueryDataProcedure>
MULTISELECT <lValue>
LINES <lValue>
HEADERS
IMAGE <acImageNames>
JUSTIFY <anJustifyValue>
HEADERIMAGES <acHeaderImages>
CELLNAVIGATION <lValue>
ROWSOURCE <cRowSource>]
COLUMNFIELDS <acColumnFields>
ALLOWAPPEND <lValue>
ALLOWDELETE <lValue>
DYNAMICDISPLAY <abDynamicDisplay>
LOCKCOLUMNS <nValue>
END GRID
Properties:
- RecNo
- Value
- Enabled
- Visible
- Row
- Col
- Width
- Height
- FontName
- FontSize
- FontBold
- ToolTip
- HeaderImages (nColumnNumber)
- Name (R)
- Virtual (D)
- Parent (D)
- Widths (D)
- MultiSelect (D)
- NoLines (D)
- Image (D)
- Justify (D)
- HelpId (D)
- Break (D)
- AllowEdit (D)
- ColumnControls (D)
- ColumnValid (D)
- Headers (D)
- CellNavigation (D)
- Items (D)
- Image (D)
- Items (D)
- LockColumns (D)
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
- Note: These properties are not available when OnDblClick
procedure
is fired by <Enter> key pressing.
Properties
Available For DynamicBackColor / DynamicForeColor
/ ColumnValid Processing:
- This.CellRowIndex
- This.CellColIndex
- This.CellValue
Properties
Available For OnSave Procedure:
- This.AppendBuffer
- This.EditBuffer
- This.MarkBuffer
- This.EditBuffer: Array of one element per edited cell. The elements has the following structure: { nLogicalRow , nLogicalCol , xValue , nRecNo }
- This.AppendBuffer: Array of one element per appended record. The elements has the following structure: { xFieldValue 1 , ... , xFieldValue n }
- This.MarkBuffer: Array of one element per record marked to be deleted or recalled. The elements has the following structure: { nLogicalRow , nRecNo , cMark ( 'D' or 'R' ) }
Events:
- OnChange
- OnSave
Methods:
- Show
- Append
- Save
- Delete
- Recall
- Hide
- SetFocus
- Release
- AddColumn ( [ nColIndex ] , [ cCaption ] , [ nWidth ] , [ nJustify ] )
-
Hints:
- 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 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.
- When RowSource
is specified, the workarea specified, must be open at
control definition.
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 , axReturnValues }
cControlType 'COMBOBOX'
(Required)
acItems
(Required)
axReturnValues (Optional)
SPINNER
{ cControlType , nRangeMin
, nRangeMax }
cControlType 'SPINNER'
(Required)
nRangeMin (Required)
nRangeMax (Required)
CHECKBOX
{ cControlType , cCheckedLabel
, cUnCheckedLabel }
cControlType 'CHECKBOX'
(Required)
cCheckedLabel (Required)
cUnCheckedLabel (Required)
Data type for each column will depend control specified.
NUMERIC TEXTBOX : NUMERIC
DATE TEXTBOX :
DATE
CHARACTER TEXTBOX : CHARACTER
SPINNER :
NUMERIC
COMBOBOX : NUMERIC (Any
type if axReturnValues is specified)
CHECKBOX : LOGICAL
Sample:
@ 10,10 GRID Grid_1 ;
WIDTH 620 ;
HEIGHT 330 ;
HEADERS {'Column 1','Column 2','Column 3','Column 4',;
'Column 5'} ;
WIDTHS {140,140,140,140,140} ;
ITEMS aRows ;
EDIT ;
COLUMNCONTROLS { {'TEXTBOX','NUMERIC','$ 999,999.99'},;
{'DATEPICKER','DROPDOWN'} ,;
{'COMBOBOX',{'One','Two','Three'}} , ;
{ 'SPINNER' , 1 , 20 } , ;
{ 'CHECKBOX' , 'Yes' , 'No' } }
Justify
constants:
- GRID_JTFY_LEFT
- GRID_JTFY_RIGHT
- GRID_JTFY_CENTER
GRID Control
improvement
- New
Get Properties:
<ParentWindowName>.<GridControlName>.ColumnCOUNT --> nColumnCount
<ParentWindowName>.<GridControlName>.ColumnHEADER ( nColIndex
)
--> cColumnHeader
<ParentWindowName>.<GridControlName>.ColumnWIDTH ( nColIndex
)
--> nColumnWidth
<ParentWindowName>.<GridControlName>.ColumnJUSTIFY ( nColIndex
)
--> nColumnJustify
<ParentWindowName>.<GridControlName>.ColumnCONTROL ( nColIndex
)
--> aColumnControl
<ParentWindowName>.<GridControlName>.ColumnDYNAMICBACKCOLOR
( nColIndex ) --> bColumnDynamicBackColor
<ParentWindowName>.<GridControlName>.ColumnDYNAMICFORECOLOR
( nColIndex ) --> bColumnDynamicForeColor
<ParentWindowName>.<GridControlName>.ColumnVALID ( nColIndex
)
--> bColumnValid
<ParentWindowName>.<GridControlName>.ColumnWHEN ( nColIndex
)
--> bColumnWhen
<ParentWindowName>.<GridControlName>.ColumnONHEADCLICK ( nColIndex
)
--> bColumnOnHeadClick
<ParentWindowName>.<GridControlName>.ColumnDISPLAYPOSITION ( nColIndex )
--> nColumnDisplayPosition
<ParentWindowName>.<GridControlName>.CellEx ( nRowIndex,
nColIndex ) --> xValue (very
more fast that .Cell)
- New Set Properties:
<ParentWindowName>.<GridControlName>.ColumnHEADER ( nColIndex
)
:= cColumnHeader
<ParentWindowName>.<GridControlName>.ColumnWIDTH ( nColIndex
)
:= [ nColumnWidth ] |
[
GRID_WIDTH_AUTOSIZE ] |
[ GRID_WIDTH_AUTOSIZEHEADER ]
<ParentWindowName>.<GridControlName>.ColumnJUSTIFY ( nColIndex
)
:= nColumnJustify
<ParentWindowName>.<GridControlName>.ColumnCONTROL ( nColIndex
)
:= aColumnControl
<ParentWindowName>.<GridControlName>.ColumnDYNAMICBACKCOLOR
( nColIndex ) := bColumnDynamicBackColor
<ParentWindowName>.<GridControlName>.ColumnDYNAMICFORECOLOR
( nColIndex ) := bColumnDynamicForeColor
<ParentWindowName>.<GridControlName>.ColumnVALID ( nColIndex
)
:= bColumnValid
<ParentWindowName>.<GridControlName>.ColumnWHEN ( nColIndex
)
:= bColumnWhen
<ParentWindowName>.<GridControlName>.ColumnONHEADCLICK ( nColIndex
)
:= bColumnOnHeadClick
<ParentWindowName>.<GridControlName>.ColumnDISPLAYPOSITION ( nColIndex )
:= nColumnDisplayPosition
<ParentWindowName>.<GridControlName>.CellEx ( nRowIndex,
nColIndex ) := xValue (very
more fast that .Cell)
<ParentWindowName>.<GridControlName>.BackGroundImage (
nAction, cPicture, nRow, nCol )
nAction
= GRID_SETBKIMAGE_NONE |
GRID_SETBKIMAGE_NORMAL |
GRID_SETBKIMAGE_TILE | GRID_SETBKIMAGE_WATERMARK
- New
Methods:
<ParentWindowName>.<GridControlName>.AddColumnEx ( [ nColIndex ],[ cCaption ],[ nWidth ],[ nJustify ],[aColumnControl] )
<ParentWindowName>.<GridControlName>.AddItemEx ( aItem, nRow )
- Set/Get
Grid New Properties/Methods with equivalent syntax:
- THIS.XXX --> where XXX is
the name of the new Grid Properties/Methods
- AddColumn,
AddColumnEx and DeleteColumn
properties now NOT clean the Grid (NOT Delete all items),
for compatibility with old behavior
of ADDCOLUMN and DELETECOLUMN:
- SET GridDeleteAllItems [ TRUE|ON ] | [
FALSE|OFF ]
- IsGridDeleteAllItems() --> Return .T. or .F.
- Set colors and display mode in GRID
cell navigation mode:
CellNavigationColor ( _SELECTEDCELL_FORECOLOR, aRGBcolor )
CellNavigationColor ( _SELECTEDCELL_BACKCOLOR, aRGBcolor )
CellNavigationColor ( _SELECTEDCELL_DISPLAYCOLOR, lBoolean )
CellNavigationColor ( _SELECTEDROW_FORECOLOR, aRGBcolor )
CellNavigationColor ( _SELECTEDROW_BACKCOLOR, aRGBcolor )
CellNavigationColor ( _SELECTEDROW_DISPLAYCOLOR, lBoolean )
- Get colors in GRID cell navigation
mode:
aRGBcolor := CellNavigationColor (
_SELECTEDCELL_FORECOLOR )
aRGBcolor :=
CellNavigationColor ( _SELECTEDCELL_BACKCOLOR )
aRGBcolor :=
CellNavigationColor ( _SELECTEDROW_FORECOLOR )
aRGBcolor :=
CellNavigationColor ( _SELECTEDROW_BACKCOLOR )