We use TextRect to write a string inside a clipping rectangle or within a limited rectangular region. Any portions of the string that fall outside the rectangle passed in the Rect parameter are clipped and don’t appear. The upper left corner of the text is placed at the point (X, Y).
Here is the working example of the implementation of an OnClose event like in the Section 7 (Getting Started with DelphiVCL III: Overview of Commonly used VCL Components):
def grdTestDrawCell(Sender, Col, Row, Rect, State):
if gdSelected in State:
Sender.Canvas.Brush.Color = clBlue # 0x00ff0000 # blue
Sender.Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, "%d @ %d" % (Col, Row))