Export (0) Print
Expand All
Expand Minimize

DataGridViewCell.MeasureTextPreferredSize Method

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)

public static Size MeasureTextPreferredSize (
	Graphics graphics,
	string text,
	Font font,
	float maxRatio,
	TextFormatFlags flags
)
public static Size MeasureTextPreferredSize (
	Graphics graphics, 
	String text, 
	Font font, 
	float maxRatio, 
	TextFormatFlags flags
)
public static function MeasureTextPreferredSize (
	graphics : Graphics, 
	text : String, 
	font : Font, 
	maxRatio : float, 
	flags : TextFormatFlags
) : Size
Not applicable.

Parameters

graphics

The Graphics used to render the text.

text

The text to measure.

font

The Font applied to the text.

maxRatio

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

flags

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

Return Value

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

Exception typeCondition

ArgumentNullException

graphics is a null reference (Nothing in Visual Basic).

-or-

font is a null reference (Nothing in Visual Basic).

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.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2015 Microsoft