Class: Grid [Obsolete]
Properties | Events | Methods | Index of Classes
A basic class which should be used for creating multi-row, multi-column entry lists.
Hierarchy
Library: Windows Application Class Library
Package: Windows.pkg
Mixins: Standard_Grid_Mixin, Standard_Object_Mixin, Multi_Item_Shadow_Mixin, Mask_form_Mixin, FloatingPopupMenu_Mixin, Auto_Setup_Mixin, RGB_Support_Temp_Mixin, Help_Mixin, Shadow_Mixin
Description
This class is obsolete. It has been replaced by the cCJGrid class.
As of revision 16.0, DataFlex includes full support for Codejock Software's COM Report Control package for creating grids. See Using Grids for more information.
Grid is a basic class which should be used for creating multi-row, multi-column entry lists. The Grid class supports data entry in data windows. The data is stored in items and may be accessed and manipulated like other objects with items. The Grid object scrolls in the display and uses a scroll bar for navigation and visual clues. Both vertical and, if required, horizontal scrolling are supported. Grids also support the ability to create resizable header labels. The Grid class supports combo forms, checkboxes, spin forms, and prompt buttons in individual columns or cells.
The dbGrid class is a data-aware class similar to the Grid class.
Sample
Object MyGrid is a Grid
Set Location to 10 10
Set Size to 100 170
Set Line_Width to 2 0
Set CurrentCellColor to clRed
Set CurrentCellTextColor to clWhite
Set CurrentRowColor to clWhite
Set CurrentRowTextColor to clNavy
Set GridLine_Mode to Grid_Visible_Both
Set Resize_Column_State to False
Set Header_Label 0 To 'Name'
Set Form_Width 0 to 100
Set Header_Label 1 To 'Due'
Set Header_Justification_Mode 1 to jMode_Right
Set Form_Width 1 to 60
Set Currency_Mask 1 to 6 2
Procedure Fill_the_List
Integer iItemCount
Clear MyData
Find gt MyData.Name
While (Found)
Send Add_Item msg_None MyData.Name
Send Add_Item msg_None MyData.Amount
If (MyData.Amount < 0) Begin
Get Item_Count to iItemCount
Set ItemColor (iItemCount-1) to clRed
End
Find Gt MyData.Name
Loop
End_Procedure
Send Fill_the_List
End_Object
Syntax
Use dfClient.pkg
Use Windows.pkg
:
Object object_name is a Grid
// object based properties
Set Size to height width
Set Location to Row Column
Set Line_Width to NumberColumns 0
Set Header_Visible_State to true|false
Set Resize_Column_State to true|false
Set CurrentCellColor to RGBColor
Set CurrentCellTextColor to RGBColor
Set CurrentRowColor to RGBColor
Set CurrentRowTextColor to RGBColor
Set Highlight_Row_State to true|false
Set GridLine_Mode to GridVisibleMode
Set Enabled_State to true|false
// Column based properties. repeat for each column
Set Status_Help col# to StatusHelpText
Set Form_Width col# to ColumnWidth
Set Form_DataType col# to type
Set Form_Mask col# to Mask
Set Numeric_Mask col# to leftDigits rightDigits {template}
Set Currency_Mask col# to leftDigits rightDigits {template}
Set Header_Label col# to HeaderLabel
Set Header_Justification_Mode col# to Mode
// Item-based properties. repeat as needed
Send Add_Item msg# ItemValue
Set ItemColor item# to RGBColor
Set ItemTextColor item# to RGBColor
Set Entry_State item# to true|false
Set Item_Shadow_State item# to true|false
Set Checkbox_Item_State item# to true|false
End_Object
Of Special Note
Grids are based on the DfBaseForm class and therefore inherit all of the item-based protocols of this class (which is actually inherited from DfBaseList). Each item in a grid is represented by a number of properties (value, message, aux_value, item_changed_state, entry_state, checkbox_item_state, etc.). In most cases, you will only deal with the value property. Be aware that all other item properties still exist.
Determining the Number of Columns and Rows in a Grid
The number of current rows can be obtained via line_size and the number of rows which are available for display of data via displayable_rows.
Creating a Grid Matrix
By default, a grid is created consisting of a single column. If you need more than one column in your grid, you must set the line_width. This is passed two parameters, the number of columns and the number of displayable rows. You should always pass 0 for the number of rows. This instructs the grid to determine the number of displayable rows based on the display size of the object. In the Studio, Line_Width is handled for you via the Grid Options dialog, unless you create columns dynamically.
Creating a List of Items
This class is designed to allow the number of items to change based on the amount of data needed when the program is being executed. Normally, the items are added into the object with the add_item and/or insert_item messages and normally this is done inside some kind of initialization procedure. However, if there is an initial set of items to be used when the object is first created, an item list can be defined in this object. We recommend that lists be filled using the add_item message and not with the static item-list construct. You will find this to be more flexible.
Grid lists do not have to be static. Items can be changed, added, inserted, and deleted. Entire lists can be deleted (delete_data) and completely rebuilt.
Navigating with Arrow Keys
By default, the up and down arrow keys navigate within the dropdown list. This can be changed to navigate between rows in the grid by setting the pbComboNavigation property to False.
RGB Colors
The color of items, rows, and cells in grids is set using RGB (red, green, blue) colors. A color setting is passed a single value representing a complex RGB color. Each individual color is represented as a number between 0 and 255. These individual red, green, and blue colors are converted to a single value by using the RGB function. This is the standard method for representing colors in Windows.
Set CurrentCellColor to (rgb(255,0,0)) // red
The rgb.pkg package contains names for most commonly used colors. It also contains names for most of the system-defined colors. You can use these replacement names when setting color values.
Set CurrentCellColor to clPurple
Set CurrentCellColor to clBtnFace // color for a button face
Scrolling
Grids support vertical and, when required, horizontal scrolling. A vertical scroll bar is provided to support vertical scrolling.
When the width of the columns exceeds the width of the grid, horizontal scrolling is enabled. Normally, a horizontal scroll bar will appear when this type of scrolling is required (although it can be disabled). The grid is always scrolled so that the current column is entirely visible. For this reason, a grid scrolls horizontally one column at a time.
Shadowing
Shadowing refers to the process of making an object or an item unavailable for data entry. Usually, the appearance of a shadowed object is changed in some way to indicate its unavailability. This class supports object shadowing. A grid will be shadowed whenever an ancestor object is shadowed or when the grid's enabled_state is set to false. In addition, individual items can be shadowed within a grid by setting the item_shadow_state property.
Masking
This class supports input and display masking for a variety of data types (text, numeric, currency, and dates). The type of masking used is determined by the object's form_datatype (which supports both masked and non-masked types) and the object's form_mask. Two additional messages, set currency_mask and set numeric_mask make it particularly easy to define currency and numeric data types and fields with a single message. Masking is supported for each column in a grid.
Header Labels
Grids often require a header description or label. Each column may contain a label and each label may be left-justified, right-justified, or centered. Headers are optional and can be disabled. When present, the size of a column can be resized by mouse dragging the header divider. This resize feature can also be disabled. Headers support mouse events and will respond to both single and double clicks. The action of these events can be controlled by the program.
Status Help
Status help is supported at the column level. All items within the same column will display the same status-help value.
Accelerator Keys
This class's accelerator keys are unchanged from those of its superclass.