vijai
vijai

Reputation:

Printform in c# 2008

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

Upvotes: 0

Views: 2531

Answers (1)

Sauron
Sauron

Reputation: 16903

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();
}

Upvotes: 1

Related Questions