TTMSFNCDataGridCell Class
Rendering object for one visible grid cell: it combines the cell data, layout, and position, paints the cell, and handles mouse and keyboard input for it.
API unit family: TMSFNCDataGridCell
Syntax
TTMSFNCDataGridCell = class
class PASCALIMPLEMENTATION TTMSFNCDataGridCell : public System::TObject
Remarks
The grid creates rendering cells only for the visible area and recycles them with ReInitialize while scrolling, so never keep a reference to a cell after the event in which you received it. The data behind a cell lives in TTMSFNCDataGridCellItem objects, not in the rendering cell.
The grid picks a descendant per cell: TTMSFNCDataGridNodeCell, TTMSFNCDataGridCheckBoxCell, TTMSFNCDataGridRadioButtonCell, TTMSFNCDataGridButtonCell, TTMSFNCDataGridProgressBarCell, TTMSFNCDataGridBitmapCell, and so on. Return your own descendant from TTMSFNCCustomDataGrid.OnGetCellClass to customise painting or input. Use the Is* / As* properties of TTMSFNCDataGridCellHelper to work with a specific descendant.
Paint order in Draw: background (fill and stroke), text, control, comment indicator, sort indicator, filter button; TTMSFNCDataGridNodeCell adds the node icon last.
Properties
| Name | Description |
|---|---|
| BitmapContainer | Bitmap container used to resolve named images, for example in HTML text or in TTMSFNCDataGridBitmapCell.BitmapName. |
| Bottom | Bottom edge of Rect. |
| ClipRect | Visible part of the grid in which the cell is painted, set by the grid before painting. |
| Column | Zero-based column index of this cell in the grid. |
| Comment | Comment text of the cell, displayed in the comment popup when the user clicks the comment indicator. |
| CommentIndicator | When True, a triangle is painted in the top-right corner of the cell to show that it has a comment; defaults to False. |
| CommentIndicatorColor | Fill colour of the comment indicator triangle; defaults to gcOrange. |
| CommentIndicatorRect | Hit and paint rectangle of the comment indicator: a 12 x 12 square (multiplied by Scale) in the top-right corner. |
| Control | Control displayed in the cell: the application control assigned by the grid, or else the built-in control of the cell class. |
| ControlAlign | Docking mode of the cell control; defaults to gcaNone. |
| ControlClipping | When True, a live control is clipped to ClipRect; defaults to True. |
| ControlMargins | Margins between the cell edges and a docked cell control. |
| ControlPosition | Placement of the cell control when ControlAlign is gcaNone; defaults to gcpCenterRight. |
| ControlRect | Rectangle occupied by the cell control, computed from the control size, ControlAlign, ControlPosition, and ControlMargins. |
| Coordinate | Column and row of this cell as a TTMSFNCDataGridCellCoord. |
| Data | Cell data item the cell renders; can be nil for a cell without data. |
| DrawElements | Parts of the cell that are painted and taken into account for layout; defaults to FullElements. |
| FilterButton | When True, a filter button is painted at the right edge of the cell; defaults to False. |
| FilterButtonRect | Rectangle of the filter button: a 16 x 16 square (multiplied by Scale) vertically centred at the right edge. |
| Height | Height of Rect. |
| IsExporting | True between BeforeExport and AfterExport, while the cell is painted for export. |
| Kind | Role of this cell in the grid layout (normal, fixed, frozen, and so on). |
| Layout | Appearance the cell is painted with: fill, stroke, sides, font, and text settings. |
| Left | Left edge of Rect. |
| Rect | Cell rectangle in the grid's local coordinate space. |
| Right | Right edge of Rect. |
| Row | Zero-based row index of this cell in the grid. |
| Scale | Scale factor applied to fonts, strokes, glyph sizes, and margins when the cell is painted; 1.0 by default. |
| SortIndicator | Sort glyph painted in the cell; defaults to gsiNone. |
| SortIndicatorRect | Rectangle of the sort indicator, placed immediately left of FilterButtonRect and vertically centred. |
| Text | Text painted in the cell: the TTMSFNCDataGridCellItem.DisplayValue of Data, or an empty string when there is no data. |
| TextRect | Rectangle in which the text is painted. |
| Top | Top edge of Rect. |
| Width | Width of Rect. |
Methods
| Name | Description |
|---|---|
| AfterExport | Called by the grid when an export pass ends; resets IsExporting to False. |
| BeforeExport | Called by the grid before the cell is painted for export; sets IsExporting to True. |
| ClearControlCache | Discards the cached bitmap of the cell control, including its entry in the shared control cache, so it is captured again on the next paint. |
| Draw | Paints the complete cell: applies the layout fill, stroke, and font, raises the before-draw notification, then calls DrawBackground and DrawContent and raises the after-draw notification. |
| DrawBackground | Paints the cell rectangle with the current fill and stroke, stroking only the TTMSFNCDataGridCellLayout.Sides of the layout. |
| DrawCommentIndicator | Paints the comment triangle in the top-right corner of the cell in CommentIndicatorColor. |
| DrawContent | Prepares the cell control and paints the content layers: text, control, comment indicator, sort indicator, and filter button. |
| DrawControl | Paints the cell control from its cached bitmap in ControlRect. |
| DrawFilterButton | Paints the filter icon in FilterButtonRect. |
| DrawSortIndicator | Paints the ascending or descending sort glyph in SortIndicatorRect, preceded by the sort order number when several columns are sorted. |
| DrawText | Paints Text in TextRect using the alignment, wrapping, trimming, and angle of the layout, clipped to the cell rectangle. |
| HandleKey | Processes a key event for the cell. The base implementation does nothing; descendants override it to react to keys. |
| HandleMouse | Processes a mouse event for the cell: clicks on the filter button, the comment indicator, and a cached control, and switching a cached control to its live version while the mouse hovers over it. |
| IsHTML | Returns True when the cell text looks like HTML markup. |
| ReInitialize | Recycles this cell for another coordinate and data item without creating a new object. |
| XYToAnchor | Returns the anchor (href) under the given position in the HTML text of the cell. |