Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Trust the Universe
Posted

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

i'm not lazy i'm just resting before i get tired.
Posted (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 by feurich
Trust the Universe
Posted (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 by feurich
Trust the Universe

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...