Reputation: 20464
In C# or VB.NET how I could write a generic function which only should need to pass a string and a font to return the measure of the font?
This is What I've tried:
Private Function Get_Text_Measure(ByVal text As String, _
ByVal font As Font) As SizeF
Using g As Graphics = ...
Return g.MeasureString(text, font)
End Using
End Function
Upvotes: 0
Views: 290
Reputation: 73442
You can use TextRenderer
return TextRenderer.MeasureText(text , font);
Upvotes: 2