TcxCanvas.DrawTexT(string,TRect,TAlignment,TcxAlignmentVert,Boolean,Boolean) Method
Draws formatted text within a specified rectangle on the canvas.
Declaration
procedure DrawTexT(const Text: string; R: TRect; AAlignmentHorz: TAlignment; AAlignmentVert: TcxAlignmentVert; AMultiLine: Boolean; AShowEndEllipsis: Boolean); overload;
Parameters
Name | Type | Description |
---|---|---|
Text | string | A drawn text string. |
R | TRect | The target rectangle on the canvas. |
AAlignmentHorz | TAlignment | Specifies the required horizontal alignment for the drawn text string ( |
AAlignmentVert | TcxAlignmentVert | Specifies the required vertical alignment for the drawn text string ( |
AMultiLine | Boolean | Specifies if the procedure can split up displayed text into multiple lines. |
AShowEndEllipsis | Boolean | Specifies if the procedure displays an ellipsis at the end of the displayed text string if it does not fit into the target rectangle. |
Remarks
Call the DrawTexT
procedure to draw a text string within the target rectangle on the current canvas. The DrawTexT
procedure uses canvas background color and font settings to draw text.
Code Example: Draw a Multi-Line Caption
The following code example demonstrates a TcxCustomGridTableView.OnCustomDrawPartBackground event handler that wraps a caption into multiple lines and displays an ellipsis at the end of the caption if it does not fit into the Group By box:
procedure TMyForm.cxgFilmsDBTableViewCustomDrawPartBackground(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxCustomGridCellViewInfo; var ADone: Boolean);
var
ABounds: TRect;
begin
ABounds := AViewInfo.Bounds;
ACanvas.FillRect(ABounds);
InflateRect(ABounds, -150, -4);
OffsetRect(ABounds, 140, 0);
ACanvas.DrawTexT('This is the Group By box. ' +
'It is used to group records by field values. ' +
'Drag a column header here to group by that field.',
ABounds, cxWordBreak or cxShowEndEllipsis);
ADone := True;
end;