DayWalker Posted April 21, 2004 Posted April 21, 2004 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: Quote
MikeJ Posted April 22, 2004 Posted April 22, 2004 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. Quote
DayWalker Posted April 22, 2004 Author Posted April 22, 2004 Thanks MikeJ but could you perhaps show me a example im lost in a thoughtless state. Quote
Machaira Posted May 12, 2004 Posted May 12, 2004 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 Quote Here's what I'm up to.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.