Xceed SmartUI for WinForms v3.6 Documentation
Xceed.SmartUI.v3.6 Assembly / Xceed.SmartUI Namespace / SmartPaint Class / MeasureString Method
The Graphics that will be used to draw the string.
The string to measure.
The font object that defines the text format of the string.
A StringFormat object that represents formatting information, such as line spacing, for the string.


In This Topic
    MeasureString Method
    In This Topic
    Retrieves the size of the specified string according to the specified font and StringFormat.
    Syntax
    'Declaration
     
    Public Shared Function MeasureString( _
       ByVal graphics As Graphics, _
       ByVal text As String, _
       ByVal font As Font, _
       ByVal format As StringFormat _
    ) As SizeF
    'Usage
     
    Dim graphics As Graphics
    Dim text As String
    Dim font As Font
    Dim format As StringFormat
    Dim value As SizeF
     
    value = SmartPaint.MeasureString(graphics, text, font, format)
    public static SizeF MeasureString( 
       Graphics graphics,
       string text,
       Font font,
       StringFormat format
    )

    Parameters

    graphics
    The Graphics that will be used to draw the string.
    text
    The string to measure.
    font
    The font object that defines the text format of the string.
    format
    A StringFormat object that represents formatting information, such as line spacing, for the string.

    Return Value

    The size of the specified string according to the specified font and StringFormat.
    Remarks

    Graphics.MeasureString always returns a value that accommodates the maximum size the text can take in the "worst case scenario". This means that if the text is regular (no bold nor italic), this size will include some padding space. This method will try to always give this spacing no matter what the FontStyle is.

    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also