Dozd

Dozd

  • NA
  • 65
  • 0

Accessing printPreviewDialog affter closing

Aug 5 2010 12:45 PM
Hi I have one form, with one button, and one printPreviewDialog. The idea is when the button is clicked printPreviewDialog should be shown. When button is clicked first time PrintPreviewDialog appears. But when you click this button another time - second time - this error message appers:"Cannot access a disposed object.Object name:'PrintPreviewDialog'.".
This is the code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MyProject
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btnShowPrintPreview_Click(object sender, EventArgs e)
{
printPreviewDialog1.Show();
}
}
}