views:

242

answers:

1

How to use the powerpack PrintForm? i want to print the winform.

+1  A: 

First use the name space

using Microsoft.VisualBasic.PowerPacks.Printing;

Suppose you have two forms say Form1 and Form2. You have a print button in Form1 and on click the button you need to print Form2. Foe this do as

Form 1

private void printButton_Click(object sender, EventArgs e)
{
      Form2 f = new Form2();
      f.Show();      
}

Form 2

private void Form2_Load(object sender, EventArgs e)
{
      this.Hide();
      printForm1.Print(this, PrintForm.PrintOption.ClientAreaOnly);
      this.Close();
}
Sauron
Thank you Ortus, its working fine.
Happy to help you.
Sauron