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 -
-
Private Sub Pr_PrintReg(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pr.PrintPage
-
Dim gr As Graphics = e.Graphics
-
Dim i As Int32
-
For i = 1 To 200
-
If i Mod 45 = 0 Then e.HasMorePages = True
-
gr.DrawString(i.ToString + " Square is - " + (i ^ 2).ToString, New Font("arial", 12), Brushes.Black, 100, (i Mod 45) * 25 + 50)
-
Next
-
e.HasMorePages = False
-
End sub
2 2927
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. -
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
-
Dim gr As Graphics = e.Graphics
-
Dim reachedEnd As Boolean = False
-
Dim i As Int16
-
Dim Y As Int16
-
Dim lastnumber As Int16
-
Static page As Int16 = 0
-
page += 1
-
If page * 60 >= 200 Then lastnumber = 200 : reachedEnd = True Else lastnumber = page * 60
-
Y = 0
-
For i = (page - 1) * 60 + 1 To lastnumber
-
Y += 1
-
gr.DrawString(i.ToString + " Square is - " + (i ^ 2).ToString, New Font("arial", 12), Brushes.Black, 100, (Y * 18 + 50))
-
Next
-
If reachedEnd Then e.HasMorePages = False Else e.HasMorePages = True
-
End Sub
Sincerelly yours George Gogiava (GGSoft)
Instead of 45 Record as disscussed above I Use 60 record per page.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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).
|
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
|
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
|
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
|
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:
....
{
| |
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...
|
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...
|
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
|
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
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |