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

HasmorePages

6
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 following code in correct manner.
I dont know where to place HasmorePages=true and HasmorePages=false
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Pr_PrintReg(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pr.PrintPage
  3.         Dim gr As Graphics = e.Graphics
  4.         Dim i As Int32
  5.         For i = 1 To 200
  6.             If i Mod 45 = 0 Then e.HasMorePages = True
  7.             gr.DrawString(i.ToString + " Square is - " + (i ^ 2).ToString, New Font("arial", 12), Brushes.Black, 100, (i Mod 45) * 25 + 50)
  8.         Next
  9.        e.HasMorePages = False
  10. End sub
Aug 18 '08 #1
2 2907
GGSoft
6
At least I have found solution Myself. Here is code:
This simple solution will help to many people.

Main logik is that, When Use e.HasMorePages = True, procedure Runs again from beginning. Use static variable to hold page number.

Other you will understand without any problem.

Expand|Select|Wrap|Line Numbers
  1. Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
  2.         Dim gr As Graphics = e.Graphics
  3.         Dim reachedEnd As Boolean = False
  4.         Dim i As Int16
  5.         Dim Y As Int16
  6.         Dim lastnumber As Int16
  7.         Static page As Int16 = 0
  8.         page += 1
  9.         If page * 60 >= 200 Then lastnumber = 200 : reachedEnd = True Else lastnumber = page * 60
  10.         Y = 0
  11.         For i = (page - 1) * 60 + 1 To lastnumber
  12.             Y += 1
  13.             gr.DrawString(i.ToString + " Square is - " + (i ^ 2).ToString, New Font("arial", 12), Brushes.Black, 100, (Y * 18 + 50))
  14.         Next
  15.         If reachedEnd Then e.HasMorePages = False Else e.HasMorePages = True
  16.     End Sub

Sincerelly yours George Gogiava (GGSoft)
Aug 18 '08 #2
GGSoft
6
Instead of 45 Record as disscussed above I Use 60 record per page.
Aug 18 '08 #3

Sign in to post your reply or Sign up for a free account.

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...
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
1
by: Kyle Walz | last post by:
I'm working on an app where each page is a like a form (not Windows form) with a set format. Using MSVB.NET 2003 with 1.1 framework. Here's some code: Private Sub PrintText(ByVal sender As...
1
by: Brenton Garman | last post by:
hello all..... I can currently print out only one page with the following code...(note it lacks the e.hasmorepages=false) Private Sub PrintToolStripButton_Click(ByVal sender As System.Object,...
2
by: Leo | last post by:
I set HasMorePages to true, but it doesn't let me jump to next page. (Of course, if I remove the HasMorePages = false in my if statement, it will create hundreds of pages). Any suggestion? Thanks...
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...
0
by: creedence | last post by:
Hello I have a problem with printing data from dataset.I dont know how to make that print is go on to the next page. I know that is something with hasmorepages = true but i dont Know how to use...
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...
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
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
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
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.