Object Reference > True DBGrid Properties > CellTop Property |
CellTop Property
The CellTop property returns the vertical offset of the top of any cell in the specified column relative to the top of the containing row in terms of the coordinate system of the grid's container.
column.CellTop
Read-only at run time. Not available at design time.
If the grid's MultipleLines property is 0 - Disabled (the default value), a single record cannot span multiple lines in the grid, and the CellTop property returns zero for all columns.
If the grid's MultipleLines property is either 1 - Variable or 2 - Fixed, a single record may span multiple lines in the grid. For columns on the first line, the CellTop property returns zero. For columns on the second line, the CellTop property returns the cell height (the grid's RowHeight property). For columns on the third line, the CellTop property returns twice the cell height, and so on.
For example, the following code places a text box on top of the grid cell in the first column of the fourth displayed row:
With TDBGrid1
Text1.Top = .Top + .RowTop(3) + .Columns(0).CellTop
End With
Note
To overlay the text box exactly on a grid cell, you may need to account for an extra pixel in the width and height, depending upon the settings of the DividerStyle and RowDividerStyle properties. In Visual Basic, if the ScaleMode property of the parent form is set to pixels, then you can simply add 1. If the ScaleMode is set to twips, then you can add the TwipsPerPixelX and TwipsPerPixelY properties of the Screen (Visual Basic) object.