View Single Post
 
Old January 17th, 2008, 09:34 AM
fdagroup fdagroup is offline
Registered User
 
Join Date: Jan 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to fdagroup
Default

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.