|
Subject:
|
Printing in VB 2005
|
|
Posted By:
|
BroadwayLion
|
Post Date:
|
6/11/2006 3:02:33 PM
|
Printing seems to be more difficult in VB 2005 than in VB6. In VB6 I made a module that I used in several programs, it would pass information directly to the print spooler:
prntxt(Data$,Font,Size,Attribute,xLoc,yLoc) were supplied, line after line until the page was complete, and then an end document command sent it to the printer, and the document would print at that time.
These new naming conventions, and the print.document object seem to be a little over my head, but this is the protocol that I need for the projects that I build.
Can anybody point me to a resource that will help me to use the printer.
Thanks,
Elias
|
|
Reply By:
|
K S Beale
|
Reply Date:
|
7/25/2006 10:05:58 AM
|
May I suggest you look at the help files for "Walkthrough: Creating a ReportViewer Report". This will allow you to access any database and generate a report.
|
|
Reply By:
|
charkins
|
Reply Date:
|
8/27/2006 11:40:25 PM
|
I could not find report template under Project ->Add New Item. Any ideas? Thanks Cal
Cal
|
|
Reply By:
|
Ankur_Verma
|
Reply Date:
|
8/29/2006 11:10:33 AM
|
Hi Elias,
Compact it may not be and it does seem like too much work but printing in VB2005 is much niftier.
Read this article http://msdn2.microsoft.com/en-us/library/9s96f6ft.aspx
You can get a printing sample at this link http://msdn2.microsoft.com/en-us/library/54z247f9.aspx
Regards Ankur
|
|
Reply By:
|
fdagroup
|
Reply Date:
|
1/17/2008 8:34:45 AM
|
Hi, I am developing a report to be printed with PrintDocument class.The problem is some parts of this report are iterated and some not.In fact report consist of three sections.The top and buttom sections are always the same but middle section is being produced from Database.The problem is how to print more than one page, I tried to use HasMorePages but somehow I think I am doing something wrong.
I need to :
1-Print top and buttom sections more than one time if the data in middle section won't fit in its specified area.
2-Be able to access each new page, if possible.That way I can repeat itereated sections and write down the continued middle section.
3-Control the behaviour of HasMorePages in order to print middle section succefully.
Since this development is company-based the code I am gonna attach is protected.It cannot be used , distributed and altered under any circumstances.I am using the following code.
Code Block
While (intLastPrintedCell < strText.GetUpperBound(0))
e.HasMorePages = True
If Not intLastPrintedCell > 0 Then
Dim intDistance As Integer = 0
For i As Integer = strText.GetLowerBound(0) To strText.GetUpperBound(0)
If intDistance <= intSplit2Distance Then
text = strText(i)
If chkShowTextInBox.Checked = True Then
e.Graphics.DrawRectangle(Pens.Black, rea("FLEFT"), rea("FTOP") + intSplit1Distance, rea("FWIDTH"), rea("FHEIGHT"))
End If
rec.X = rea("FLEFT")
rec.Y = rea("FTOP") + intSplit1Distance + intDistance
rec.Height = rea("FHEIGHT")
rec.Width = rea("FWIDTH")
e.Graphics.DrawString(text, printFont, brsh, rec, frmt)
intDistance = intDistance + rec.Height + intFieldDistance
'e.HasMorePages = False
intLastPrintedCell = i
Else
'intLastPrintedCell = i
Exit For
'
End If
Next
Else
Dim intDistance As Integer = 0
For i As Integer = intLastPrintedCell To strText.GetUpperBound(0)
If intDistance < intSplit2Distance Then
text = strText(i)
If chkShowTextInBox.Checked = True Then
e.Graphics.DrawRectangle(Pens.Black, rea("FLEFT"), rea("FTOP") + intSplit1Distance, rea("FWIDTH"), rea("FHEIGHT"))
End If
rec.X = rea("FLEFT")
rec.Y = rea("FTOP") + intSplit1Distance + intDistance
rec.Height = rea("FHEIGHT")
rec.Width = rea("FWIDTH")
e.Graphics.DrawString(text, printFont, brsh, rec, frmt)
intDistance = intDistance + rec.Height + intFieldDistance
'e.HasMorePages = False
intLastPrintedCell = i
Else
'e.HasMorePages = True
'intLastPrintedCell = i + 1
'
End If
Next
End If
End While
e.HasMorePages = False
I'd apperciate any help.If you have more information about the code contact me directly.
Remember!This code snippet is protected by international laws.
|
|
Reply By:
|
fdagroup
|
Reply Date:
|
1/24/2008 10:45:12 AM
|
Hey everyone, me again.Does anyone know how to print to a file? I mean like after finished working with PrintPageEventArgs graphics, save that out put to a file.
|
|
Reply By:
|
Ankur_Verma
|
Reply Date:
|
2/19/2008 10:22:45 AM
|
Here is a hint, just search around a bit on PrintToFile and how to use it :)
Regards Ankur
|
|
Reply By:
|
Ankur_Verma
|
Reply Date:
|
2/19/2008 10:28:28 AM
|
As an aside, if you were printing in VB6 you would assign this flag to Printer class's PrintAction property. VB 2005 is backward compatible for most purposes and if it aint for some, you always have VB6 namespace at your disposal.
Regards Ankur
|