473,671 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HasmorePages

6 New Member
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=tr ue and HasmorePages=fa lse
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 2927
GGSoft
6 New Member
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 New Member
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
2890
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 pleasure). For a single page, the print preview (and an actual print) are OK. Getting the .HasMorePages doesn't seem to be working for me here (unless I'm missing something).
3
8354
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
1476
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 Object, ByVal ev As PrintPageEventArgs) Dim brush As Brush = New SolidBrush(Color.Black) Dim font As Font = New Font("Arial", 10, FontStyle.Regular) ' first page
1
2452
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, ByVal e As System.EventArgs) Handles PrintToolStripButton.Click 'Print file from the ToolStrip Me.PrintDialog1.ShowDialog() PrintDocument1.Print() End Sub
2
7899
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 in advance. Leo My code to call the print event: .... {
1
11182
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 paint the next page on top of the original page. In a sample data case where the source is long enough to fill three pages, I end up with four calls to pd_PrintPage which render onto two printed sheets. Historical posts in this forum from 2003 and...
6
4602
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 is closes the print file. The effect is that it prints all my pages but creates a print job for each page. So if I print 100 pages I get 100 print jobs. The only way I went around this was to put all my page-filling code within...
0
1564
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 it. Here is my code, so every help is greatful. Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles
0
1849
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 intRowPos <= 10 Then e.HasMorePages = False
0
8403
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8828
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8605
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8677
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7446
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6238
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4417
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.