Ciao ,
non so se ti serve ma puoi provare così :
Sul click di un bottone inserisci questo codice :
e poi scrivi questa sub :codice:Dim Pd As Printing.PrintDocument Try streamToPrint = New System.IO.StreamReader(Nome_del_tuo_file) Try printFont = New Font("Arial", 10) Pd = New Printing.PrintDocument AddHandler Pd.PrintPage, AddressOf Me.pd_PrintPage Pd.Print() Finally streamToPrint.Close() End Try Catch ex As Exception MessageBox.Show(ex.Message) End Try
Dovrebbe funzionare !!!codice:Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As Printing.PrintPageEventArgs) Dim linesPerPage As Single = 0 Dim yPos As Single = 0 Dim count As Integer = 0 Dim leftMargin As Single = ev.MarginBounds.Left Dim topMargin As Single = ev.MarginBounds.Top Dim line As String = Nothing ' Calculate the number of lines per page. linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics) ' Print each line of the file. While count < linesPerPage line = streamToPrint.ReadLine() If line Is Nothing Then Exit While End If yPos = topMargin + count * printFont.GetHeight(ev.Graphics) ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat) count += 1 End While ' If more lines exist, print another page. If Not (line Is Nothing) Then ev.HasMorePages = True Else ev.HasMorePages = False End If End Sub
Il report è andato ?
Ciao alla prossima

Rispondi quotando