PrintDialog and UserControl

  • Thread starter Thread starter mphanke
  • Start date Start date
M

mphanke

Hi,

I wrote a userControl w/ a toolbar.

One button is supposed to open the PrintDialog. When I use the control
in a different project and click that button - the form simply closes
and the application continues working?

Any suggestions why this behavour occures??

Martin


##SNIPPET##

private void toolBar1_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
switch(toolBar1.Buttons.IndexOf(e.Button))
{
case 0: // Printer Selection
try
{
MessageBox.Show(this, "000");
PrintDialog pd = new PrintDialog();

pd.Document = printPreviewControl1.Document;

if(pd.ShowDialog()==DialogResult.OK)
{
printPreviewControl1.Document.PrinterSettings = pd.PrinterSettings;
}
pd.Dispose();
}
catch(Exception ex)
{
MessageBox.Show(this, "Source:\n"+ex.Message+"\nSource:\n"+ex.Source);
}
break;
 
Back
Top