Article View: free.it.visual-basic
Article #297Ok giochiamo con la stampa
From: noizn
Date: Mon, 26 Jun 2006 21:43
Date: Mon, 26 Jun 2006 21:43
81 lines
2669 bytes
2669 bytes
Nel codice che riporto di seguito ho un problema, quando finisco di stampare
mi rimane il documento nella coda di stampa e non viene inviato finch� non
iniziao una nuova stampa, cosa che non succede se il documento che stampo a
solo una paggina.Come posso risolvere? c'� qualcosa che dimentico? grazie in
anticipo.
ovviamente PrRMA � un'array che riempio prima. e prc e una variabile che mi
serve da contatore dichiarata come private nel form. Nel frattempo cmq
questo � un'esempio concreto di utilizzo delle funzioni di stampa del nostro
caro .net.
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e
As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
'Di seguito dichiaro il carattere
'i margini del foglio
'e l'altezza della riga
Dim mFont As New Font("Courier New", 12)
Dim xPos As Single = e.MarginBounds.Left
Dim yPos As Single = e.MarginBounds.Top
Dim lineHeight As Single = mFont.GetHeight(e.Graphics)
Dim ric, nome, rec, ogg As String 'Valori da sparare in stampa
Dim IxPage As Integer = 20 'Elementi pert pagina
Dim i As Integer = 0
With e.Graphics
Do
If PrC + i >= PrRMA.Length - 1 Then
e.HasMorePages = False
PrintDocument1.Dispose()
Exit Do
End If
ric = PrRMA(PrC + i).id
nome = PrRMA(PrC + i).Nome
rec = PrRMA(PrC + i).rec
ogg = PrRMA(PrC + i).Product
.DrawString(ric & " " & nome & " " & rec, mFont, Brushes.Black, xPos, yPos)
yPos += lineHeight
.DrawString(ogg, mFont, Brushes.Black, xPos, yPos)
yPos += lineHeight * 1.5
i += 1
If i = (IxPage - 1) Then
PrC += i
e.HasMorePages = True
Exit Do
End If
Loop
End With
End Sub
Technical Details
Message-ID:
<44a054cd$0$979$5fc30a8@news.tiscali.it>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!transit.news.xs4all.nl!xs4all!border2.nntp.ams.giganews.com!nntp.giganews.com!tiscali!newsfeed1.ip.tiscali.net!draco.tiscalinet.it!news-f2.tiscali.it!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: f94ee,6a069722d6388934,start X-Google-Attributes: gidf94ee,public X-Google-Language: ITALIAN,ASCII Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!transit.news.xs4all.nl!xs4all!border2.nntp.ams.giganews.com!nntp.giganews.com!tiscali!newsfeed1.ip.tiscali.net!draco.tiscalinet.it!news-f2.tiscali.it!not-for-mail Reply-To: "noizn" <noizn@tiscali.it> From: "noizn" <noizn@tiscali.it> Newsgroups: free.it.visual-basic Subject: Ok giochiamo con la stampa Date: Mon, 26 Jun 2006 23:43:11 +0200 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-RFC2646: Format=Flowed; Original Lines: 83 Message-ID: <44a054cd$0$979$5fc30a8@news.tiscali.it> Organization: Tiscali SpA NNTP-Posting-Host: 84.220.51.17 X-Trace: 1151358157 news.tiscali.it 979 84.220.51.17:2541 X-Complaints-To: abuse@tiscali.it