hi, can u help me, what can i do to print a form, example: in form1 there is a button that will print the form2 that has registration form.

it is possible or other ways? please help

Recommended Answers

All 3 Replies

You can make use of the PrintForm class from the Power Packs.

For example:

Public Class Form2

    Public WriteOnly Property _PrintForm As Boolean
        Set(value As Boolean)
            If value = True Then
                Dim pf As New PrintForm
                    pf.Form = Me
                    pf.PrintAction = PrintToPrinter
                    pf.Print()
            End If
        End Set
    End Property

End Class

Then to call it from form1:

Public Class Form1
    Private btnPrint_Click(ByVal sender As Object,ByVal e As EventArgs) Handles btnPrint.Click
        Form2._PrintForm = True
    End Sub
End Class

Or, you can manually print by using the PrintDocument event of a printing job.

This will require the use of the Graphics class.

commented: PrintForm to the rescue :) +8

If you're printing a registration form, you probably don't want any of the extra stuff, like the control box or any buttons, to be printed. Something like this might work:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    'make any controls you don't want printed invisible
    Button3.Visible = False

    'print everything visible in the client area(no control box or form title)
    PrintForm1.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.CompatibleModeClientAreaOnly)

    'then make them visible again
    Button3.Visible = True
End Sub

The resolution of printform is low and hoe to fix itl? that is make it high

commented: 1st post. Try next time to make it timely. -2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.