PrintDialog and UserControl

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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top