473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Printdocument hadmorepages

Hallo, i'm having troubles by printing on more pages.

I have a counter in the PrintDocument1_PrintPage(..) and i would like to
start a new page every 3 counts.

If tried it this way:

If (i + 1) Mod 3 = 0 Then
e.HasMorePages = True

End If


Part of my code:

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

Try

e.Graphics.DrawString("TKD", New Font("Arial", 20, FontStyle.Bold),
Brushes.DarkGreen, 60, 50)

e.Graphics.DrawString("Overzicht Leveranciers", New Font("Arial", 15,
FontStyle.Bold), Brushes.Black, 60, 100)

e.Graphics.DrawString("-----------------------------------------------------
------------------------------------", New Font("Arial", 15,
FontStyle.Bold), Brushes.Black, 60, 120)

Dim i As Int32

For i = 0 To DgridLeveranciers.VisibleRowCount - 2

Dim Hoogte As Int32 = i * 320

'titels

e.Graphics.DrawString("id:", New Font("Arial", 10, FontStyle.Regular),
Brushes.Black, 400, 170 + Hoogte)

e.Graphics.DrawString("Firmanaam:", New Font("Arial", 12, FontStyle.Bold),
Brushes.Black, 70, 170 + Hoogte)

....
'gegevens

e.Graphics.DrawString(DgridLeveranciers.Item(i, 0), New Font("Arial", 10,
FontStyle.Regular), Brushes.Black, 420, 170 + Hoogte)

e.Graphics.DrawString(DgridLeveranciers.Item(i, 1), New Font("Arial", 12,
FontStyle.Bold), Brushes.Black, 190, 170 + Hoogte)

........

If (i + 1) Mod 3 = 0 Then

e.HasMorePages = True

End If

Next i

'aanduiden dat dit de laatste pagina is

e.HasMorePages = False

Catch

MessageBox.Show("Er is een fout opgetreden: " & vbCrLf & Err.Number & ": " &
Err.Description, "Fout!", MessageBoxButtons.OK, MessageBoxIcon.Warning)

End Try

End Sub


Nov 20 '05 #1
3 1356
Hi,

If you set e.hasmorepages to true it will recall the print document
print event to print a new page. It does not start a new page then. Here
is a simple example.

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal
e As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
Dim g As Graphics = e.Graphics
Static intItem As Integer = 0
Dim y As Integer = 0
Dim bDraw As Boolean = True

Do Until Not bDraw
y += 15
g.DrawString(intItem.ToString, Me.Font, Brushes.Black, 10, y)
intItem += 1
bDraw = (intItem Mod 3 <> 0)
Loop

If intItem = 18 Then
intItem = 0
Else
e.HasMorePages = True
End If
End Sub

Ken
-------------------
"Stijn Vanpoucke" <st*****@hotmail.com> wrote in message
news:c7*********@reader08.wxs.nl...
Hallo, i'm having troubles by printing on more pages.

I have a counter in the PrintDocument1_PrintPage(..) and i would like to
start a new page every 3 counts.

If tried it this way:

If (i + 1) Mod 3 = 0 Then
e.HasMorePages = True

End If


Part of my code:

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage

Try

e.Graphics.DrawString("TKD", New Font("Arial", 20, FontStyle.Bold),
Brushes.DarkGreen, 60, 50)

e.Graphics.DrawString("Overzicht Leveranciers", New Font("Arial", 15,
FontStyle.Bold), Brushes.Black, 60, 100)

e.Graphics.DrawString("-----------------------------------------------------
------------------------------------", New Font("Arial", 15,
FontStyle.Bold), Brushes.Black, 60, 120)

Dim i As Int32

For i = 0 To DgridLeveranciers.VisibleRowCount - 2

Dim Hoogte As Int32 = i * 320

'titels

e.Graphics.DrawString("id:", New Font("Arial", 10, FontStyle.Regular),
Brushes.Black, 400, 170 + Hoogte)

e.Graphics.DrawString("Firmanaam:", New Font("Arial", 12, FontStyle.Bold),
Brushes.Black, 70, 170 + Hoogte)

...
'gegevens

e.Graphics.DrawString(DgridLeveranciers.Item(i, 0), New Font("Arial", 10,
FontStyle.Regular), Brushes.Black, 420, 170 + Hoogte)

e.Graphics.DrawString(DgridLeveranciers.Item(i, 1), New Font("Arial", 12,
FontStyle.Bold), Brushes.Black, 190, 170 + Hoogte)

.......

If (i + 1) Mod 3 = 0 Then

e.HasMorePages = True

End If

Next i

'aanduiden dat dit de laatste pagina is

e.HasMorePages = False

Catch

MessageBox.Show("Er is een fout opgetreden: " & vbCrLf & Err.Number & ": "
&
Err.Description, "Fout!", MessageBoxButtons.OK, MessageBoxIcon.Warning)

End Try

End Sub



Nov 20 '05 #2
"Stijn Vanpoucke" <st*****@hotmail.com> schrieb
Hallo, i'm having troubles by printing on more pages.

I have a counter in the PrintDocument1_PrintPage(..) and i would like
to start a new page every 3 counts.

[...]

For i = 0 To DgridLeveranciers.VisibleRowCount - 2

[...]

If (i + 1) Mod 3 = 0 Then

e.HasMorePages = True

End If

Next i

'aanduiden dat dit de laatste pagina is

e.HasMorePages = False

It doesn't make sense to set e.HasMorePages /within/ the loop because you
overwrite the value /after/ the loop. The printpage event is raised once per
page. After you printed the page (Drawstring), set e.HasMorePages to
indicate whether another page should be printed.

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
thanks a lot I managed to get it work!
"Ken Tucker [MVP]" <vb***@bellsouth.net> schreef in bericht
news:OG***************@tk2msftngp13.phx.gbl...
Hi,

If you set e.hasmorepages to true it will recall the print document print event to print a new page. It does not start a new page then. Here
is a simple example.

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
Dim g As Graphics = e.Graphics
Static intItem As Integer = 0
Dim y As Integer = 0
Dim bDraw As Boolean = True

Do Until Not bDraw
y += 15
g.DrawString(intItem.ToString, Me.Font, Brushes.Black, 10, y)
intItem += 1
bDraw = (intItem Mod 3 <> 0)
Loop

If intItem = 18 Then
intItem = 0
Else
e.HasMorePages = True
End If
End Sub

Ken
-------------------
"Stijn Vanpoucke" <st*****@hotmail.com> wrote in message
news:c7*********@reader08.wxs.nl...
Hallo, i'm having troubles by printing on more pages.

I have a counter in the PrintDocument1_PrintPage(..) and i would like to
start a new page every 3 counts.

If tried it this way:

If (i + 1) Mod 3 = 0 Then
e.HasMorePages = True

End If


Part of my code:

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage

Try

e.Graphics.DrawString("TKD", New Font("Arial", 20, FontStyle.Bold),
Brushes.DarkGreen, 60, 50)

e.Graphics.DrawString("Overzicht Leveranciers", New Font("Arial", 15,
FontStyle.Bold), Brushes.Black, 60, 100)

e.Graphics.DrawString("----------------------------------------------------- ------------------------------------", New Font("Arial", 15,
FontStyle.Bold), Brushes.Black, 60, 120)

Dim i As Int32

For i = 0 To DgridLeveranciers.VisibleRowCount - 2

Dim Hoogte As Int32 = i * 320

'titels

e.Graphics.DrawString("id:", New Font("Arial", 10, FontStyle.Regular),
Brushes.Black, 400, 170 + Hoogte)

e.Graphics.DrawString("Firmanaam:", New Font("Arial", 12, FontStyle.Bold), Brushes.Black, 70, 170 + Hoogte)

...
'gegevens

e.Graphics.DrawString(DgridLeveranciers.Item(i, 0), New Font("Arial", 10, FontStyle.Regular), Brushes.Black, 420, 170 + Hoogte)

e.Graphics.DrawString(DgridLeveranciers.Item(i, 1), New Font("Arial", 12, FontStyle.Bold), Brushes.Black, 190, 170 + Hoogte)

.......

If (i + 1) Mod 3 = 0 Then

e.HasMorePages = True

End If

Next i

'aanduiden dat dit de laatste pagina is

e.HasMorePages = False

Catch

MessageBox.Show("Er is een fout opgetreden: " & vbCrLf & Err.Number & ": " &
Err.Description, "Fout!", MessageBoxButtons.OK, MessageBoxIcon.Warning)

End Try

End Sub




Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeffry van de Vuurst | last post by:
Hi, I have a PrintDocument that I preview in a PrintPreviewControl. Now I run the app on a pc without any printers installed and when I want to preview the PrintDocument I get an...
3
by: Palli Olafs | last post by:
Hi Is it possible to save the PrintDocument as file without using a printer?
3
by: Randy | last post by:
Hello, I'm trying to print a dataGrid using PrintDocument control. My datagrid has about 23 columns so it is fairly wide. When I use the PrintControl, it prints only the part of the dataGrid that...
2
by: Robert Hooker | last post by:
Hi, I'm curious to know if I'm doing something wrong here, or if this is just mind-numbingly slow for a reason. In a simple WindowsFormsApplication: public Form1() { // Required for...
1
by: Frank Rizzo | last post by:
Hello, I have an OCX control on my WinForm (don't ask, i have to use it) and it generally works well. One of the methods of the OCX prints to an hDC (device context handle for history buffs). ...
0
by: active | last post by:
Dim mPD As PrintDocument Dim mPrinternameSaved As PrintDocument Public WriteOnly Property PrintDocument() As PrintDocument Set(ByVal value As PrintDocument) mPD = value mPrinternameSaved = mPD...
3
by: Mika M | last post by:
Hi all! I have made an application for printing simple barcode labels using PrintDocument object, and it's working fine. Barcode printer that I use is attached to the computer, and this...
2
by: Steve | last post by:
I'm trying real hard to set the printer resolution for a PrintDocument. It appears that the printer is already set to 300 x 300 dpi, which is JUST what I want. But the Margins and PrintableArea...
2
by: bp | last post by:
Hi, I try to use my own PreviewDialog with a PrinPreviewControl, to preview a document of type MyPrintDocument, and I want to implement the PrintRange functionnality (print some pages between 2...
1
by: kig25 | last post by:
Hello, When using the VB.NET PrintDocument class, I seem to be encountering an issue where the sub pd_PrintPage handles PrintDocument.PrintPage (upon continuing if HasMorePages = true) will...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.