DataGridViewCell.MeasureTextPreferredSize Method (Graphics, String, Font, Single, TextFormatFlags)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the ideal height and width of the specified text given the specified characteristics.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

static member MeasureTextPreferredSize : 
        graphics:Graphics *
        text:string *
        font:Font *
        maxRatio:float32 *
        flags:TextFormatFlags -> Size

Parameters

graphics
Type: System.Drawing.Graphics

The Graphics used to render the text.

text
Type: System.String

The text to measure.

font
Type: System.Drawing.Font

The Font applied to the text.

maxRatio
Type: System.Single

The maximum width-to-height ratio of the block of text.

flags
Type: System.Windows.Forms.TextFormatFlags

A bitwise combination of TextFormatFlags values to apply to the text.

Return Value

Type: System.Drawing.Size

A Size representing the preferred height and width of the text.

Exception Condition
ArgumentNullException

graphics is null.

-or-

font is null.

ArgumentOutOfRangeException

maxRatio is less than or equal to 0.

InvalidEnumArgumentException

flags is not a valid bitwise combination of TextFormatFlags values.

If multiple lines are required and the specified formatting allows it, the size returned includes the combined height of all lines.

.NET Framework
Available since 2.0
Return to top
Show: