Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an application in vb.net with OleDb database.
Here is my code to print text in Richtextbox.
C#
Dim font3 As Font = New Drawing.Font("arial", 10, FontStyle.Underline)
e.Graphics.DrawString(Me.RBC_Seriestxt.Text, font3, Brushes.Black, 170, 660)

But when print the text, it prints all text in single line and its not limited to size of Richtextbox in the form.
So what to do ?
Posted
Updated 18-May-14 2:45am
v2

1 solution

try below
VB
Dim formatter as StringFormat  = New StringFormat()
formatter.LineAlignment = StringAlignment.Center
formatter.Alignment = StringAlignment.Center

Dim rectangle As RectangleF = New RectangleF(0, 0, richTextBox.Width, richTextBox.Height)
Dim font3 As Font = New Drawing.Font("arial", 10, FontStyle.Underline)
e.Graphics.DrawString(Me.RBC_Seriestxt.Text, font3, Brushes.Black, rectangle, formatter)


And check below article as well
Draw Over WinForms Controls[^]
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900