Basic Print Question?

DayWalker

Well-known member
Joined
Jul 9, 2003
Messages
51
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:
 
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.
 
You need to define a rect in which the text is printed:
Code:
    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
 
Back
Top