Printing in Visual Basic 2005
Learn how to print ListView items from a Visual Basic 2005 inventory application.
The text of this article is not in this database — only its details are. The old site it was published on is gone, but the Internet Archive kept a copy: Printing in Visual Basic 2005

Sabith KpPosted Dec 20, 2009, 7:29 PM EST
Here is the modified code please check and fix your problem Public Sub PrintBIll() Dim PSize As Integer = ListItems.Items.Count Dim PHi As Double With PrintDocument1.DefaultPageSettings Dim Ps As PaperSize PHi = PSize * 20 + 350 Ps = New PaperSize("Cust", 800, PHi) .Margins.Top = 15 .Margins.Bottom = 20 .PaperSize = Ps End With headfont = New Font("Courier New", 16, FontStyle.Bold) tableFont = New Font("Courier New", 10) titlefont = New Font("Courier New", 12, FontStyle.Bold) X1 = PrintDocument1.DefaultPageSettings.Margins.Left Dim pageWidth As Integer With PrintDocument1.DefaultPageSettings pageWidth = .PaperSize.Width - .Margins.Left - .Margins.Right End With X2 = X1 + 120 X3 = X2 + pageWidth * 0.5 W1 = X2 - X1 W2 = X3 - X2 W3 = pageWidth - X3 'If u want to print Directly then PrintDocument1.Print() 'Elseif u want print after print preview then u pls use this code PrintPreviewDialog1.Document = PrintDocument1 PrintPreviewDialog1.ShowDialog() itm = 0 End Sub
wasimPosted Dec 20, 2009, 2:07 PM EST
I am trying to implement this code for printing ListView items and having following problems in the above code: Ps = New PaperSize("Cust", 800, PHi).Margins.Top = 15.Margins.Bottom = 20.PaperSize = Ps This line of code gives an error that Margins is not a member of System.Drawing.Printing.papersize str = Spacing(Format(Listitems.Items(itm).SubItems(8).Text, "Fixed"), 10) The above line of code gives an error that Spacing is not declared. Please advise how i can fix these problems to implement the code successfully. Thanks
Ahmad ghPosted Nov 27, 2008, 9:46 PM EST
i wish someone will help me to make my project,,, i cant work with visual basic 2005 because i used to work with visual basic 0.6,, my project name is ( daily medicines consumption), so i need combobox include all medicines name (it's about 60 items) and 3 textbox (strength*frequency*duration) and another textbox to show the calculation result, for example (AMITRYPILINE 10 MG) (2)*(3)*(30) = (180) then button for next enter. and every time i enter new medicine the result will be added to the previous result (for each medicine separately). finaly, button to print all medicines names with the final consumptions result for each medicines separately for example: (amitryptiline 10 mg = 4500) (fluvoxamin 50 mg = 670) i wish my project is clear and i wish i can find help, at least some steps and codes... thanks everybody.... (mixa)