Method

Graphics.DrawString


Warning

This item was deprecated in version 2019r2. Please use Graphics.DrawText as a replacement.

Description

Draws the text at the specified location and in the current color. The current color is set with the ForeColor property.

Notes

The X parameter specifies the distance from the left of the Graphics object in pixels. The Y parameter specifies the baseline for the text. The optional WrapWidth parameter specifies the width (in pixels) at which Text should wrap. The Text will wrap if WrapWidth is provided and Condense is False (The default is False). If WrapWidth is omitted, then Text will print on one line, even if the window or RectControl is too narrow to contain the text. If the optional Condense property is True, DrawString truncates the string to fit into the space specified by WrapWidth and uses an ellipsis ("...") to indicate that there is additional text that is not shown. The default values of WrapWidth and Condense are zero and False, respectively. The default behavior is to print the string on one line.

Sample code

This code draws text in red Helvetica 16-point:

g.ForeColor = &cff0000
g.TextFont = "Helvetica"
g.TextUnit = FontUnits.Point
g.TextSize = 16
g.DrawString("Hello world", 10, 130)

Compatibility

All project types on all supported operating systems.