Font.DrawText Method (Sprite, String, Rectangle, DrawTextFormat, Color)

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Draws formatted text.

Namespace:  Microsoft.WindowsMobile.DirectX.Direct3D
Assembly:  Microsoft.WindowsMobile.DirectX (in Microsoft.WindowsMobile.DirectX.dll)


Public Function DrawText ( _
    sprite As Sprite, _
    value As String, _
    rectangle As Rectangle, _
    format As DrawTextFormat, _
    color As Color _
) As Integer
Dim instance As Font
Dim sprite As Sprite
Dim value As String
Dim rectangle As Rectangle
Dim format As DrawTextFormat
Dim color As Color
Dim returnValue As Integer

returnValue = instance.DrawText(sprite, _
    value, rectangle, format, color)
public int DrawText(
    Sprite sprite,
    string value,
    Rectangle rectangle,
    DrawTextFormat format,
    Color color
int DrawText(
    Sprite^ sprite, 
    String^ value, 
    Rectangle rectangle, 
    DrawTextFormat format, 
    Color color
member DrawText : 
        sprite:Sprite * 
        value:string * 
        rectangle:Rectangle * 
        format:DrawTextFormat * 
        color:Color -> int 


  • rectangle
    Type: System.Drawing.Rectangle
    A reference to a Rectangle structure that contains the rectangle, in logical coordinates, in which the text is being formatted.

Return Value

Type: System.Int32
If the function succeeds, the return value is the height of the text in logical units. If Center or Bottom is specified in the format parameter, the return value is the offset from the top to the bottom of the drawn text. If the function fails, the return value is 0.


This method must be called from inside of a BeginScene-method-to-EndScene-method code block.

Unless the NoClip format is used, this method clips the text so that it does not appear outside of the specified rectangle. All formatting is assumed to have multiple lines unless the SingleLine format is specified.

If the selected font is too large for the rectangle, this method does not attempt to substitute a smaller font.

This method supports only fonts whose escapement and orientation are both zero.

.NET Framework Security


Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Compact Framework

Supported in: 3.5, 2.0

See Also


Font Class

Font Members

DrawText Overload

Microsoft.WindowsMobile.DirectX.Direct3D Namespace