Dim text2 As String = _
"Draw text in a rectangle by passing a RectF to the DrawString method."
Dim font2 As New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point)
Try
Dim rect2 As New Rectangle(30, 10, 100, 122)
' Specify the text is wrapped.
Dim flags As TextFormatFlags = TextFormatFlags.WordBreak
TextRenderer.DrawText(e.Graphics, text2, font2, rect2, Color.Blue, flags)
e.Graphics.DrawRectangle(Pens.Black, Rectangle.Round(rect2))
Finally
font2.Dispose()
End Try
string text2 = "Draw text in a rectangle by passing a RectF to the DrawString method.";
using (Font font2 = new Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point))
{
Rectangle rect2 = new Rectangle(30, 10, 100, 122);
// Specify the text is wrapped.
TextFormatFlags flags = TextFormatFlags.WordBreak;
TextRenderer.DrawText(e.Graphics, text2, font2, rect2, Color.Blue, flags);
e.Graphics.DrawRectangle(Pens.Black, Rectangle.Round(rect2));
}