Word Wrapping with Draw String
-
Hello everybody. I'm trying to make the contents of a textbox, if they don't fit in a page to wrap and use the line underneath etc etc. So far i can clip the string in the given rectangle i have indicate with the setclip command. Other than that i can't make it work. Here is a part of the code: 'Create string to draw. Dim drawString As String = txtComment.Text Dim drawString1 As String = imageToLoad Dim drawFont As New Font("Arial", 0.4, FontStyle.Regular, GraphicsUnit.Millimeter) Dim drawFont1 As New Font("Arial", 0.6, FontStyle.Regular, GraphicsUnit.Millimeter) Dim drawBrush As New SolidBrush(Color.Black) ' print filename Dim drawPoint As New PointF(0.0F, -27.0F) 'print comments Dim drawPoint1 As New PointF(0.0F, 90.0F) If chkComment.Checked = True Then e.Graphics.SetClip(New Rectangle(0, 0, 100, 100)) e.Graphics.DrawString(drawString, drawFont1, drawBrush, drawPoint1) End If e.Graphics.DrawString(drawString1, drawFont, drawBrush, drawPoint) ' There are no more pages. e.HasMorePages = False The textbox in question is the txtComment.Text. Any help please? Thank you :) Still trying to find the way
-
Hello everybody. I'm trying to make the contents of a textbox, if they don't fit in a page to wrap and use the line underneath etc etc. So far i can clip the string in the given rectangle i have indicate with the setclip command. Other than that i can't make it work. Here is a part of the code: 'Create string to draw. Dim drawString As String = txtComment.Text Dim drawString1 As String = imageToLoad Dim drawFont As New Font("Arial", 0.4, FontStyle.Regular, GraphicsUnit.Millimeter) Dim drawFont1 As New Font("Arial", 0.6, FontStyle.Regular, GraphicsUnit.Millimeter) Dim drawBrush As New SolidBrush(Color.Black) ' print filename Dim drawPoint As New PointF(0.0F, -27.0F) 'print comments Dim drawPoint1 As New PointF(0.0F, 90.0F) If chkComment.Checked = True Then e.Graphics.SetClip(New Rectangle(0, 0, 100, 100)) e.Graphics.DrawString(drawString, drawFont1, drawBrush, drawPoint1) End If e.Graphics.DrawString(drawString1, drawFont, drawBrush, drawPoint) ' There are no more pages. e.HasMorePages = False The textbox in question is the txtComment.Text. Any help please? Thank you :) Still trying to find the way
If you use the DrawString variant that takes a Rectangle, it will wrap the string for you. Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
-
If you use the DrawString variant that takes a Rectangle, it will wrap the string for you. Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
Thank you Christian. I used Dim LayoutRen As RectangleF = New RectangleF(0, 90, 100, 300) e.Graphics.DrawString(drawString, drawFont1, drawBrush, LayoutRen) and it work like a charm. Thank again! :-D Still trying to find the way