Problem : we want to print only active child form on the click of button that is place on mdiparent form or we want to print only active or selected child form content
try This: we can print the windows form with the help of PrintForm component of Powerpacks. basically Powerpacks Printform allows us to easily print the windows form in a simple report.
now you want to print active child form then you can try following steps:
1. Add Printfrom component on mdiparent form.
(Drag a PrintForm component onto the Form from the Visual Studio Toolbox)
2. use this code on the click of ‘Print’ button.
Private Sub ButtonPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonPrint.Click Dim frm As Form = Me.ActiveMdiChild Me.PrintForm1.Form = frm Me.PrintForm1.PrinterSettings.DefaultPageSettings.Landscape = True Me.PrintForm1.Print() End Sub
we can also set the left margin and right margin of the print page like this:
Me.PrintForm1.PrinterSettings.DefaultPageSettings.Margins.Left = 5
Me.PrintForm1.PrinterSettings.DefaultPageSettings.Margins.Right = 5