Home > Language Reference > Classes
Grid Class
+ Object
+ Display
+ UIComponent
+ Control
+ Grid
Description
The Grid class implements the behaviours specific to the grid. Like all the classes derived from UIComponent, this class is not instantiable, cloneable or derivable. The only instances available to the programmer are those automatically generated by HB++ when you place a control on a form.

A grid is a control that allows the display and entry of data in the form of rows and columns. Each column can appear in multiple forms.
Columns types are defined at design time and can be the following ones :
The Grid object is a complex object particularly adapted for the Palm OS® plateform. It displays data and supports in place editing. It is especially useful for displaying data in a list where the number of items is important. Unlike the List object, it is not necessary to populate the whole control, the items only need to be loaded in memory when being displayed. This considerably reduces the memory occupied - In other words, you don't populate a Grid object with data, but with references that will be subsequently used to obtain the data on the fly.
The number of columns as well as their types and attributes must be specified at design time as well as the number of Visible items:
| Properties window | Columns definition dialog box |
![]() | ![]() |
Note: The 'Extra properties' frame contains specific attributes for each type of column selected in the dialog box. Thus a column of type 'Text' will not have the same extra properties as a column of type 'Popup' (see also Columns design time properties). The 'Preview' frame shows the appearance of the Grid object depending on the attrributes entered in this dialog box.
There are two ways to specify the number of rows in the Grid object; either by using the Rows property or by adding rows one by one with the AddItem method which also allows to specify for each line added an associated value in the ItemData property. When you use the Grid class to display the contents of a database, it is useful to store in the ItemData property a unique identifier allowing the record to be retrieved from this value. For records accessed from the StreamRecord class, you store the value of its UniqueId property in ItemData. For records accessed with the Recordset class, you store the value of its UniqueId property in ItemData.
Whichever method is used to set the number of rows in the Grid object, the Rows property returns the number of items in the Grid object.
The LoadItem event is raised for each row displayed indicating the index of the relevant row, the value ItemData associated with the row as well as a Variant array corresponding to the different columns in the row that are affected.
For columns of type 'User Draw', the DrawItem event is received for each one that must be drawn, indicating the index of the row and the index of the relevant column, the ItemData value associated with the row as well as the coordinates and size of the drawing area.
The Click event is raised when the user clicks on the Grid control. It allows the application to know the row and column clicked on as well as the the value of the ItemData property associated with this row.
The Change event is raised when a cell is edited. The types of column that allow editing are 'Text', 'Text with note', 'CheckBox' and 'Popup'.
For columns of type 'Text' or 'Text with note', the Change event is raised if a change occurs in the edit zone and uniquely when another cell becomes active. This implies that a PenDown event event is raised for the new cell before the Change event is raised for the 'Text' or 'Text with note' zone has been modified. One of the parameters of the Change event is a Variant vNewValue which contains the new value of the cell.
For columns of type 'Popup', the List property references a List object for which items should be added using the AddItem method.
The Masked property sets or reads whether a row in the Grid object must be masked or not. For a cell to be masked, the corresponding column must be set with this attribute ( see columns design time properties) and the Masked property of the row must be also set to True.
The RemoveItem method deletes rows from the Grid object using their index.
The Scrollbar property associates a grid with a Scrollbar control or SpinButton control, allowing the user to scroll the rows contained in the Grid control.
The TopItem property defines the index of the first row displayed in a Grid.
The Row and Col properties return the row and column index of the currently selected Grid item. Row is in the range of 0 to Rows -1 and Col is in the range of 0 to the count of columns (see Columns) -1.
The SelectItem method allow to select a cell and the HighLight method allow to highlight a cell.
Members
| Members | Description |
| AddItem | Add an item to the Grid control |
| Change | Event raised when the contents of cell is modified by the user. |
| Click | Raised when the user clicks the control. |
| Col | Column index of the currently selected grid item |
| ColumnType | Type of a given column. |
| DrawItem | Event raised when a User draw cell have to be draw. |
| Highlight | Highlight a cell |
| ItemData | Value associated with a row. |
| List | Reference to a popup object. |
| LoadItem | Occurs when the Grid control requires data to display. |
| Masked | Mask or show a row. |
| Redraw | Determines whether the control is updated each time the list is modified. |
| ReloadItem | Reload the data associated with one row. |
| RemoveItem | Remove a row from the grid control. |
| Row | Row index of the currently selected grid item |
| Rows | Number of rows in a grid. |
| Scrollbar | Reference to the scrollbar associated with a grid. |
| SelectItem | Sets the selected cell in a grid control. |
| TopItem | Index of the top row displayed. |
| Inherited from Control | Description |
| DrawFocusRing | Draws the focus ring. |
| GotFocus | Event raised when the control gains the focus. |
| Layer | Layer to which the control belongs. |
| LostFocus | Event raised when the control loses the focus. |
| NavFlags | Navigation flags for the control. |
| RemoveFocusRing | Erase the focus ring. |
| Tag | String associated with the control. |
| Visible | Indicates if a control is visible or not. |
| Inherited from UIComponent | Description |
| ComponentToScreen | Converts coordinates relative to a component into coordinates relative to the screen. |
| FiveWayNavigator | Event raised when the user presses one of the 5-way navigator keys. |
| Height | Element height. |
| Left | Distance between the left edge of the form and the left edge of the element. |
| Move | Moves or resizes an element. |
| PenDown | Event raised when the user touches an UI element with the stylus. |
| PenMove | Event raised when the user moves the stylus. |
| PenUp | Event raised when the user releases the stylus. |
| ScreenToComponent | Converts coordinates relative to the screen into coordinates relative a component. |
| Top | Distance between the top edge of the form and the top edge of the element. |
| UIRef | Internal reference to a control. |
| Width | Element width. |
| Inherited from Display | Description |
| Arc | Draws an arc. |
| BackColor | Background color. |
| BatchLimit | Size of the graphics instruction buffer. |
| CoordinateSystem | Coordinates system. |
| CopyArea | Efficiently copies part of a Display object to another. |
| DrawFont | Font used to draw the text. |
| Flush | Empties the graphics instruction buffer. |
| FontMetrics | Returns a FontMetrics object describing the physical charateristics of the currently active font. |
| ForeColor | Foreground color. |
| GetPixel | Queries the color of a given pixel. |
| hWin | Returns the window handle. |
| Line | Draws a line. |
| Oval | Draws a circle or ellipse. |
| Pattern | Defines the pattern used to fill drawings. |
| Polygon | Draws a polygon. |
| PutPixel | Sets the color of a pixel. |
| Rectangle | Draw a rectangle. |
| ResID | Identifier of the resource associated with the object. |
| ScaleFont | Enable or disable font scaling. |
| TextColor | Text color. |
| TextOut | Draw text. |
| Inherited from Object | Description |
| ClassID | Returns the type identifier corresponding to the actual class of the object. |
| Implements | Determines whether the object implements the features of a given class. |
| Iterate | Event raised to iterate over the elements of a container object. |
| Recipient | Recipient of events sent by the object. |
| Serialize | Event raised to serialize the object content into a stream. |
System requirements
| System | Minimal version | Remarks |
| Palm OS | Palm OS 3.0 | N/A |