Hi,
Can some one pls tell me how to print a form with labels.The code Ive tried is like this:
VB Code:
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, _ ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles _ pd1.PrintPage Dim myPaintArgs As New PaintEventArgs(e.Graphics, New Rectangle(New _ Point(0, 0), Me.Size)) Dim ctl As Control Static fntHeadingFont As New Font("Arial", 12, FontStyle.Bold) Try For Each ctl In Me.Controls If TypeOf ctl Is Label Then 'Me.InvokePaint(Me, myPaintArgs) 'I need to get the object to print all labels on page in the exact postion End If Next e.HasMorePages = False Catch ex As Exception MessageBox.Show("An error occurred while printing", _ ex.ToString()) End Try End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click PrintPreviewDialog1.ShowDialog() End Sub Private Sub printbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles printbutton.Click Try pd1.Print() Catch ex As Exception MessageBox.Show("An error occurred while printing", _ ex.ToString()) End Try End Sub


Reply With Quote
