|
-
August 4th, 2008, 11:45 AM
#1
Printing
Okay, so i have this code. I need to print in a specific format and in landscape. So far, all I get is one line of jumbled text with all the lines in it. Apparently, VbNewLine doesn't make the printer go to a new line. Anyway to do that and make it print in landscape? Because currently, it won't print in landscape, instead it prints one line in normal mode.
Code:
Sub print_formated()
Dim doc As PrintDocument = New PrintDocument
Dim printer As PrintDialog = New PrintDialog
printer.Document = doc
printer.ShowDialog()
AddHandler doc.PrintPage, AddressOf PrintPageHandler
doc.PrinterSettings().DefaultPageSettings.Landscape = True
doc.Print()
End Sub
Private Sub PrintPageHandler(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim canvas As Graphics = e.Graphics
canvas.DrawString("WO#: " & wonumtxb.Text & vbTab & vbTab & "Maintenance Control TimeSheet" & vbTab & vbNewLine, _font, Brushes.Black, 0, 0)
canvas.DrawString("Name: " & emplasttxb.Text & " | " & " Emp No: " & empnumcmb.SelectedItem & " | " & " Area " & convert_area(EmpCraft.Text) & " | " & " Lettered Shift: " & shiftnumcmb.SelectedItem & " | " & " Time: " & Date.Today.Hour.ToString & ":" & Date.Today.Minute.ToString & " | " & " Shift No: " & (shiftnumcmb.SelectedIndex + 1).ToString & " | " & " Supv: " & shiftnametxb.Text & " | " & " Date: " & Date.Today.ToString & " | " & vbNewLine, _font, Brushes.Black, 0, 0)
canvas.DrawString("Job No." & vbTab & " | Acct " & vbTab & " | Cntr " & vbTab & " | Work Code " & vbTab & " | Description " & vbTab & vbTab & vbTab & " | Act Time " & vbTab & " | " & vbNewLine, _font, Brushes.Black, 0, 0)
End Sub
I was thinking it may just be better to create a string in the background with all this crap then print that string, or have a hidden richtextbox that i create it in.
Microsoft Visual Basic 2008 Express Edition
.NET Framwork 3.5 Beta SP1
-
August 5th, 2008, 06:49 AM
#2
Re: Printing
 Originally Posted by ccubed
I was thinking it may just be better to create a string in the background with all this crap then print that string, or have a hidden richtextbox that i create it in.
How about a crystal report?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
0100 1101 0110 1001 0110 0011 0110 1000 0110 0001 0110 0101 0110 1100 0010 0000 0100 0101 0110 1100 0110 1100 0110 0101 0111 0010
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|