Back to Devexpress

TcxCanvas.DrawTexT(string,TRect,TAlignment,TcxAlignmentVert,Boolean,Boolean) Method

vcl-cxgraphics-dot-tcxcanvas-dot-drawtext-x28-system-dot-string-system-dot-types-dot-trect-system-dot-classes-dot-talignment-cxclasses-dot-tcxalignmentvert-system-dot-boolean-system-dot-boolean-x29.md

latest3.9 KB
Original Source

TcxCanvas.DrawTexT(string,TRect,TAlignment,TcxAlignmentVert,Boolean,Boolean) Method

Draws formatted text within a specified rectangle on the canvas.

Declaration

delphi
procedure DrawTexT(const Text: string; R: TRect; AAlignmentHorz: TAlignment; AAlignmentVert: TcxAlignmentVert; AMultiLine: Boolean; AShowEndEllipsis: Boolean); overload;

Parameters

NameTypeDescription
Textstring

A drawn text string.

| | R | TRect |

The target rectangle on the canvas.

| | AAlignmentHorz | TAlignment |

Specifies the required horizontal alignment for the drawn text string (Text).

| | AAlignmentVert | TcxAlignmentVert |

Specifies the required vertical alignment for the drawn text string (Text).

| | 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:

delphi
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;
cpp
void __fastcall TMyForm::cxgFilmsDBTableViewCustomDrawPartBackground(TcxCustomGridTableView *Sender,
  TcxCanvas *ACanvas, TcxCustomGridCellViewInfo *AViewInfo, bool &ADone)
{
  TRect 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 | cxShowEndEllipsis);
  ADone = true;
}

See Also

TcxCanvas.DrawTexT(System.String,System.Types.TRect,System.Integer,System.Boolean,cxGraphics.TcxRotationAngle) Procedure

TcxCanvas.DrawTexT(System.String,System.Types.TRect,System.Integer,System.Boolean) Procedure

TcxCanvas Class

TcxCanvas Members

cxGraphics Unit