| | |
Printing problem
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2007
Posts: 24
Reputation:
Solved Threads: 0
I have written software that creates a text file, the text file contains colums of data. When I view and print the text file using notepad all the colums line up correctly. I am now trying to print the text file using a button on my form but every time I print it all the colums are no longer lined up :-(
This is the code that I'm using to do the print.
Am I missing a setting somewhere???
Thanks for any help you can give me
Simon
This is the code that I'm using to do the print.
VB.NET Syntax (Toggle Plain Text)
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage Dim LinesPerPage As Single = 0 Dim yPosition As Single = 0 Dim count As Integer = 0 Dim leftMargin As Single = e.MarginBounds.Left Dim topMargin As Single = e.MarginBounds.Top Dim strLine As String = Nothing Dim printFont As Font = Me.lblFadeRate.Font Dim myBrush As New SolidBrush(Color.Black) 'Work out the number of lines per page, using the MarginBounds. LinesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics) 'Iterate over the string using the StringBuilder, printing each line. strLine = MyStreamReader.ReadLine While count < LinesPerPage 'Calculate the next line position based on the height on the font according 'to the printing device yPosition = (topMargin + (count * printFont.GetHeight(e.Graphics))) 'draw the next line in the stream e.Graphics.DrawString(strLine, printFont, myBrush, leftMargin, yPosition, New StringFormat()) count += 1 strLine = MyStreamReader.ReadLine End While 'check to see if there is another page left to print If MyStreamReader.EndOfStream = False Then e.HasMorePages = True Else e.HasMorePages = False MyStreamReader.Close() 'Close stream reader End If End Sub
Am I missing a setting somewhere???
Thanks for any help you can give me
Simon
![]() |
Similar Threads
- Printing problem with Qbasic (Legacy and Other Languages)
- O/T. HTML printing problem.......... (HTML and CSS)
- Printing Problem (Visual Basic 4 / 5 / 6)
- Low Quality in VB when printing with printer.paintpicture (Visual Basic 4 / 5 / 6)
- Problem printing from IE6 (Web Browsers)
- Simple answer for vexing problem? (OS X)
- Weird IE6 printing problem... (Web Browsers)
Other Threads in the VB.NET Forum
- Previous Thread: Length of WAV
- Next Thread: basic operations..
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account arithmetic array assignment basic binary bing button buttons center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist excel file-dialog firewall folder ftp google hardcopy image images insert isnumericfuntioncall listview login math memory mobile ms navigate net networking opacity output passingparameters peertopeervideostreaming picturebox picturebox1 port print problemwithinstallation project reports" save savedialog searchbox serial soap sorting string table tcp temp text textbox timer toolbox trim update updown upload useraccounts usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio web wpf






It worked a treat 