feurich Posted November 24, 2003 Posted November 24, 2003 HI there, I'm trying to print the values from controls that are created at runtime. Does anybody have some guidelines for me ? How do I acces those controls Thanks in advance. Cire Quote Trust the Universe
bpayne111 Posted November 26, 2003 Posted November 26, 2003 print the values meaning properties? where are you having issues with this? just the printing part or accessing the control's values during runtime? brandon Quote i'm not lazy i'm just resting before i get tired.
feurich Posted November 26, 2003 Author Posted November 26, 2003 Printing guidelines in general I meant printing guidelines in VB.NET in general. :D Quote Trust the Universe
feurich Posted November 27, 2003 Author Posted November 27, 2003 (edited) OK Figured that out OK I figured out how to make printing work. It's actually pretty easy. Create under a button_click event a try cath error handler. But use it to handle the printing see the attached files. Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click '*** Print using a error handler to catch problems Try Dim PrintDoc As New PrintDocument AddHandler PrintDoc.PrintPage, AddressOf Me.PrintPatch PrintDoc.Print() '*** Print the Text Catch ex As Exception MessageBox.Show(" There is a problem printing, please check if there's paper in the printer", ex.ToString) End Try End Sub and this one. Private Sub PrintPatch(ByVal sender As Object, ByVal ev As PrintPageEventArgs) '*** '*** Loop through the controls collection and Build the print string. Dim oControl As Control For Each oControl In Me.Controls If oControl.Name <> "btnPrint" And oControl.Name <> "cboIndexSet" And oControl.Name <> "cboPatch" Then If TypeOf oControl Is TextBox Then strPrint = strPrint & oControl.Text & vbCrLf End If If TypeOf oControl Is ListBox Then strPrint = strPrint & oControl.Text End If If TypeOf oControl Is DateTimePicker Then strPrint = strPrint & oControl.Text End If End If Next '*** Get the Print String and font settings ev.Graphics.DrawString(Me.Controls.Item(1).Text.ToString, New Font("Free 3 of 9 Extended", 20, FontStyle.Regular), Brushes.Black, 120, 120) ev.HasMorePages = False '*** Only one page to print End Sub as you can see i'm printing out Barcodes now I want to print the readable text underneed the barcode. How can I switch between font type per line ???? Edited November 27, 2003 by feurich Quote Trust the Universe
feurich Posted December 1, 2003 Author Posted December 1, 2003 (edited) AnyOne Does anyone knows how to switch between Fonts during printing. I have to print a barcode and underneeth the Barcode the readable text. Cire Edited December 1, 2003 by feurich Quote Trust the Universe
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.