473,395 Members | 1,530 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,395 software developers and data experts.

Help hasmorepages datagridview print

Hi,

Hope someone can help me
I have a datagridview sith data

Code below works fine if I print the data if there is only 1 page (without
using
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
If intRowPos <= 10 Then
e.HasMorePages = False
Else
e.HasMorePages = True
End If
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!)

If I include "If e.HasMorePages... " as below everything goes wrong
and I cant find the wright code to print more pages if the datagridview as
more data
-------------------------------------------------------------------------------------------------------

Many thanks in advance

'***Code Print datagridview***

Imports System.Data.OleDb
Imports System.Data
Imports System.Web
Imports System.Globalization

Public Class PrintDGV
Dim WithEvents PrtDoc As New Drawing.Printing.PrintDocument
Private intRowPos As Int16

Private Sub btnPrintInvoice_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPrintInvoice.Click

Dim PreviewDialog As New PrintPreviewDialog()
PreviewDialog.Document = PrtDoc
PreviewDialog.WindowState = FormWindowState.Maximized
PreviewDialog.PrintPreviewControl.Zoom = 1.0
PreviewDialog.ShowDialog()

End Sub

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

Dim IntLijnteller As Integer = 1
Dim Borstel As New Drawing.SolidBrush(Color.Black)
Dim MyFont As New Font("Bookman Old Style", 12, FontStyle.Regular)
Dim TekstAfmetingen As New SizeF
Dim IntPrintHo As Integer

Static oColumnLefts As New ArrayList
Static oColumnWidths As New ArrayList
Static oColumnTypes As New ArrayList
Static iX As Integer = 0

Dim nTop As Int16 = CShort(e.MarginBounds.Top)
Dim nLeft As Int16 = CShort(e.MarginBounds.Left)
Dim strRef3 As String = ""
Dim strArtikel4 As String = ""
Dim intAantal5 As Integer = 0
Dim dPrijs7 As Decimal
Dim dKorting8 As Decimal
Dim dTotaal10 As Decimal

IntPrintHo = 100
Dim rowNumber As Integer = 1
Dim row As DataGridViewRow

e.Graphics.PageUnit = GraphicsUnit.Millimeter
MyFont = New Font("Bookman Old Style", 12, FontStyle.Regular)

Dim potlood As New Drawing.Pen(Color.DarkBlue)
potlood.Width = 0.1

IntLijnteller = 1
IntPrintHo = 100

For Each row In dgvFacturenInfo.Rows
strRef3 = String.Empty
strArtikel4 = String.Empty
intAantal5 = CInt(Nothing)

'Printing Reference
strRef3 = CStr(dgvFacturenInfo.Rows(row.Index).Cells(2).Valu e)
e.Graphics.DrawString(strRef3, MyFont, Borstel, 15, IntPrintHo)

'Printing text
strArtikel4 = CStr(dgvFacturenInfo.Rows(row.Index).Cells(3).Valu e)
e.Graphics.DrawString(strArtikel4, MyFont, Borstel, 40, IntPrintHo)

Dim recf5 As New RectangleF(10, IntPrintHo, 133, IntPrintHo)
Dim hh5 As New StringFormat
hh5.Alignment = StringAlignment.Far

'Printing Quantity
intAantal5 = CInt(CStr(dgvFacturenInfo.Rows(row.Index).Cells(4) .Value))
e.Graphics.DrawString(CStr(intAantal5), MyFont, Borstel, recf5, hh5)

'Printing Price
dPrijs7 = CType(((dgvFacturenInfo.Rows(row.Index).Cells(9).V alue)), Decimal)
Dim recf7 As New RectangleF(10, IntPrintHo, 155, IntPrintHo)
Dim hh7 As New StringFormat
hh7.Alignment = StringAlignment.Far
dPrijs7 = CType(((dgvFacturenInfo.Rows(row.Index).Cells(9).V alue)), Decimal)
e.Graphics.DrawString(CStr(CDec(Format(dPrijs7, "#,###0.00"))), MyFont,
Borstel, recf7, hh7)

'Printing Profit
dKorting8 = CType(((dgvFacturenInfo.Rows(row.Index).Cells(10). Value)),
Decimal)
e.Graphics.DrawString(CStr(Format(dKorting8, "0.00")), MyFont, Borstel, 170,
IntPrintHo)

'Printing Totals
Dim recf10 As New RectangleF(10, IntPrintHo, 190, IntPrintHo)
Dim hh10 As New StringFormat
hh10.Alignment = StringAlignment.Far
dTotaal10 = CDec(((dgvFacturenInfo.Rows(row.Index).Cells(13).V alue)))
e.Graphics.DrawString(Format(dTotaal10, "#,###0.00").ToString, MyFont,
Borstel, recf10, hh10)
IntPrintHo = IntPrintHo + 5
intRowPos = intRowPos + 1

'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! His makes the wrong outprint
If intRowPos <= 10 Then
e.HasMorePages = False
Else
e.HasMorePages = True
End If
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Next

End Sub

End Class
Mar 25 '07 #1
0 1067

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

Similar topics

8
by: Mr. B | last post by:
VB.net (standard) I'm experiencing some difficulties in printing multiple pages using Print Preview. The following is my main parts of my printing subs (excess info deleted for your viewing...
5
by: Mr. B | last post by:
This is driving me NUTZ!!! I've been screwing around on this for a week now. And I have tried to find examples similar to what I have (nada). Got lots of streaming a TXT file... bah! I am...
3
by: DGeorge | last post by:
I have a problem where after setting the HasMorePages = True will not print the 2nd Pages. Does anybody have an idea or knows this problem. Thanks for any advice
2
by: Lars Netzel | last post by:
I have figured out everything I need to print what I need to print except to handle the HasMorePages property.. I'm looping thru a DataTable and sometimes the number of rows exceeds the lines on...
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...
6
by: moti | last post by:
Whenever I use PrintDocument.Print() to print a page it goes to PrintDocument_PrintPage and stays there forever unless I set e.HasMorePages to False. When I set it to False it prints the page but...
4
by: DeWittds | last post by:
I have asked before and got little responce, So I try and try again. The code below prints the data in the same place but does not advance the page. I can see the lblnumber change but print in...
0
by: =?Utf-8?B?UGxheWE=?= | last post by:
I am using a print preview dailog in vb .net and when I open the dialog there are multiple pages. Everytime I press the print button only the last page prints. I have tried so many things but...
0
by: Scotty | last post by:
Hi, Hope someone can help me I have a datagridview sith data Code below works fine if I print the data if there is only 1 page (without using '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! If...
2
by: GGSoft | last post by:
Please Can't understand how to use HasMorepages. I spent a lot of time on this task. but I have no result. For examle I want to print every 45 record on each new page. Please Rewrite the...
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: 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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.