 |
| Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book:
Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 11th, 2006, 03:02 PM
|
|
Registered User
|
|
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Printing in VB 2005
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
|
|

July 25th, 2006, 10:05 AM
|
|
Registered User
|
|
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

August 27th, 2006, 11:40 PM
|
|
Registered User
|
|
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I could not find report template under Project ->Add New Item. Any ideas?
Thanks
Cal
Cal
|
|

January 17th, 2008, 09:34 AM
|
|
Registered User
|
|
Join Date: Jan 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

January 24th, 2008, 11:45 AM
|
|
Registered User
|
|
Join Date: Jan 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

February 19th, 2008, 11:22 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Here is a hint, just search around a bit on PrintToFile and how to use it :)
Regards
Ankur
|
|

February 19th, 2008, 11:28 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|
 |