Hi,
I want to print some record(s) from dataset.table(t bname)
using PrintPreviewDai log and PrintDocument. But It has a
infinity loop error.
I use a class to control the print procedure.
Here is my code.
Public Sub New(ByVal dbset As DataSet)
jobFont = New Font("Times New Roman", 12)
myJobSet = dbset
pDoc = New PrintDocument()
pDoc.DefaultPag eSettings.Lands cape = True
AddHandler pDoc.PrintPage, AddressOf printJobSchedul e
pDialog.Documen t = pDoc
pDialog.ShowDia log()
End Sub
'PrintDocument
Private Sub printJobSchedul e(ByVal sender As Object, ByVal
ev As PrintPageEventA rgs)
JobCount = myJobSet.Tables ("Orders").Rows .Count
reJob = myJobSet.Tables ("Orders").Rows .Count
yPos = 120
curJob = 0
JobPerPage =5
Do While JobCount >= 1
For count = 1 To jobPerPage
'Print some record(s) here
curJob += 1
reJob -= 1
If reJob = 0 Then
Exit For
End If
Next
JobCount -= 5
If JobCount > 0 Then
ev.HasMorePages = True
End If
Loop
End Sub
IS my code got any mistake??
Thanks,
KWOK 4 3159
Hi Kwok,
I did test it with this code.
It did not give an infinity loop.
Maybe you can too bring your variables into the routine, then you don't have
the problem that maybe somewhere outside it can be change
\\\\\\
Dim JobCount As Integer = 1000
Dim reJob As Integer = 100
Dim curJob As Integer = 0
Dim JobPerPage As Integer = 5
Do While JobCount >= 1
Dim count As Integer
For count = 1 To jobPerPage
'Print some record(s) here
curJob += 1
reJob -= 1
If reJob = 0 Then
Exit For
End If
Next
JobCount -= 5
If JobCount > 0 Then
Dim dummy As Boolean = True
End If
//////////////
Cor
Hi, Cor
thanks for your sugestion, but I tried your code, It also
did a infinity loop. The infinity loop happened in
PrintPreviewDia log load a document.
here is my code
dim pDoc as PrintDocument
dim pDialog as new PrintPreviewDia log()
pDoc = New PrintDocument()
pDoc.DefaultPag eSettings.Lands cape = True
AddHandler pDoc.PrintPage, AddressOf printJobSchedul e
pDialog.Documen t = pDoc
pDialog.ShowDia log() -----Original Message----- Hi Kwok, I did test it with this code. It did not give an infinity loop. Maybe you can too bring your variables into the routine,
then you don't havethe problem that maybe somewhere outside it can be change \\\\\\ Dim JobCount As Integer = 1000 Dim reJob As Integer = 100 Dim curJob As Integer = 0 Dim JobPerPage As Integer = 5 Do While JobCount >= 1 Dim count As Integer For count = 1 To jobPerPage 'Print some record(s) here curJob += 1 reJob -= 1 If reJob = 0 Then Exit For End If Next JobCount -= 5 If JobCount > 0 Then Dim dummy As Boolean = True End If ////////////// Cor
.
Kwok,
I have made a new project and pasted this code into the sub with the load
document event.
The document shows up.
Therefore I think there cannot be an infinity loop.
But maybe you can try it too and tell me what I did wrong?
Cor
Cor,
sorry, I made a mistake from your code. But I tried your
code (I also create a new windows form project), it only
showed one page which including all records.
I changed your code.
If JobCount > 0 Then
*Dim dummy As Boolean = True
* I change above code to
ev.hasMorePage = true
End If
loop
then It made a infinity loop.
I tried use boolean to check more page then
write a ev.hasMorePage above for loop or under if statment.
but it is also infinity
SO, can you have some idea to what is the code wrong??
how to print more pages??
Thanks
Kwok This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael A. Covington |
last post by:
By default, my PrintPreviewDialog is coming out too small. What is the best
way to control its size and position? Ideally, I'd just like to maximize
it. Thanks!
|
by: Randy |
last post by:
Hello all,
I'm trying to print using PrintPreviewDialog. What's happening is that the
PrintPreviewDialog shows the correct information to be printed, but when I
click the print icon, it prints a blank page. If I comment out the
printPreviewDialog1.ShowDialog();
and just do a
printDocument1.Print();
instead, it prints all the pages like a champ. Anyone know what I'm doing
wrong?
Thanks
|
by: sachin |
last post by:
How to customize PrintPreviewDialog, such that, addition of a new button, change the functionality of existing button should be possible programatically. Sample code will help a lot. Moreover, what happens before the document gets displayed in PrintPreviewDialog, i.e. whether entire document gets copied in printer driver spool or only 1 or 2 pages?
please guide
regards
|
by: Harry J. Smith |
last post by:
I am using the PrintPreviewDialog Window Form from the Toolbox.
It displays my RichTextBox contents correctly, but when I click on the Print
icon on this form it prints one blank page and no text.
How can I fix this to print the text that is being displayed?
Here is the code I use to bring up the form:
string stringText = helpTextOut.Text;
|
by: Jack E. Hardie |
last post by:
When I call the PrintPreviewDialog, the resulting default window and zoom
size are too small to read. I have figured out how to resize the window,
but can someone help me with the call to preset the zoom to 100% instead of
the default Auto?
My code is as follows:
' The PrintPreviewDialog is associated with the PrintDocument as the
preview is
' rendered, the PrintPage event is triggered. This event is passed a
graphics
' context where...
| |
by: Darrell Wesley |
last post by:
Is there anyway to hook the PrintDialog to the printer icon on the
PrintPreviewDialog?
I know that you can print a document using the PrintDialog but it does not
allow previewing and the PrintPreview dialog does not allow you to select a
printer - is there a good and simple way to get around these problems.
My users would like to select a specific printer while looking at the
Preview window.
|
by: jacopomeucci |
last post by:
hi all.
I've a problem with PrintPreviewDialog in c#.
I've done a form with a ListViewControl and i tried to print the data
contents in this listview.
I've read the ListViewControl via a WHILE cicle and i've done document
then i've send it to the PrintPreviewDialog...end it seems to be
perfect but when i click the printer button on the PrintPreviewDialog
|
by: Richard MSL |
last post by:
I am using PrintPreviewDialog to preview a file. There is a button that the
user can press, which seems to print the file to the default printer. I would
like to capture a click on that button so that I can present a PrintDialog,
print some files in a special way, etc. But there does not seem to be an
event among the PrintPreviewDialog members to do this? Or perhaps I missed
it? I would appreciate any suggestions. Thanks.
|
by: choupi |
last post by:
Hello,
Is there a way to call a printDialog from a printPreviewDialog (from print
icon for example)?
Indeed, the print icon in the printpreviewdialog prints directly the
document without lunching the printdialog (i.e. the user can't choose the
print parameters).
Thanks a lot.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| |