Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I was wondering if anyone could help. I hav created a document with VB

,The user enters in a description into a textbox and when they click the button it prints out what they have typed on to the document. The only thing is sometimes the string is long so it goes off the page to the right and does not start at a new line (vbcrlf). Here is a piece of my code:

 

Dim strCode As String

strCode1 = txtCode1.Text

e.Graphics.DrawString(strCode1, fntInput, Brushes.Black, 40, 425)

 

Any help would be great thanks. :rolleyes:

Posted
I would set a width of a few characters, and then measure out that many characters into different parts of a string array. Then, you can loop through them, and display them into the form.
  • 3 weeks later...
Posted

You need to define a rect in which the text is printed:


   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

       Dim pd As New printdocument()

       AddHandler pd.PrintPage, AddressOf PrintPage

       pd.Print()
   End Sub

   Private Sub PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs)

       Dim rect As New RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height)

       e.Graphics.DrawString(TextBox1.Text, Me.Font, Brushes.Black, rect)

   End Sub

Here's what I'm up to.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...