g.drawstring() string going out of page

  • Thread starter Thread starter Bauer
  • Start date Start date
B

Bauer

I am new to GDI+.I am drawing a string on the Win form
using GDI+. My string content is long and it does not
have any "vbcrlf". The whole string is displayed in a
single line and is getting truncated. Can anyone tell me
how to take the win form bounds and display the long
content on multiple lines.
The same is happening when i am printing the same string.
how do i take the page settings and print the page

Thanks in advance
 
I got it to display in multiple lines in Win form using
the g.drawstring(string,f,b,RectangleF)
But I need to print the same content on multiple lines.
Can anyone guide me on this
 
* said:
I got it to display in multiple lines in Win form using
the g.drawstring(string,f,b,RectangleF)
But I need to print the same content on multiple lines.

You can use the 'Graphics' object's 'MeasureString' method to get the
size the string will take on the printer. Then you can adjust the
position where the next line is printed accordingly.
 
Is there no way, where I can set the page settings of the
page to print and then print the string accordingly on
multiple lines.
 
Hi,

Try this.
Dim g As Graphics = e.Graphics

Dim h As Integer

Dim strOut As String

strOut = "This is a really really really long string to print out on the
page."

h = CInt(g.MeasureString(strOut, Me.Font, 250).Height)

Dim rdraw As New RectangleF(10, 10, 250, h)

g.DrawString(strOut, Me.Font, Brushes.Black, rdraw)



Ken

-------------------------------
 
-----Original Message-----
Hi,

Try this.
Dim g As Graphics = e.Graphics

Dim h As Integer

Dim strOut As String

strOut = "This is a really really really long string to print out on the
page."

h = CInt(g.MeasureString(strOut, Me.Font, 250).Height)

Dim rdraw As New RectangleF(10, 10, 250, h)

g.DrawString(strOut, Me.Font, Brushes.Black, rdraw)



Ken

-------------------------------




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top