Version

GetLabelSizePixels(String,LabelStyle,Font,Rectangle) Method

Gets the size of a specified string using a specified LabelStyle and an alternate Font.
Syntax
'Declaration
 
Public Overloads Shared Function GetLabelSizePixels( _
   ByVal str As String, _
   ByVal style As LabelStyle, _
   ByVal font As Font, _
   ByVal bounds As Rectangle _
) As SizeF
public static SizeF GetLabelSizePixels( 
   string str,
   LabelStyle style,
   Font font,
   Rectangle bounds
)

Parameters

str
The string to measure.
style
The LabelStyle object to use when measuring the string.
font
The font to use for measuring the string.
bounds
The bounding rectangle in context.

Return Value

A SizeF object containing the height and width of the label.A SizeF object containing the height and width of the label.
Remarks

Unlike the GetStringSizePixels method, this method accounts for the Orientation property of the given LabelStyle object, which affects how high or wide a label will be.

For example, a string+font measured at 50x100 pixels (HxW), but oriented vertically, would yield a SizeF of 100x50 using this method.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, 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