I'm using Visual Studio 2008, .net Framework 3.5 for a Windows forms client-server app that I'm working on. There is a weird bug when I run the program and try to print. The print dialog box opens, but I have to click the OK button twice for it to work. After the second click it works fine, no errors. When I put a breakpoint on: if (result == DialogResult.OK) , the breakpoint doesn't trigger until the second click. Here is the code:
private void tbPrint_Click(object sender, EventArgs e)
{
try
{
printDialog1.Document = pDoc;
DialogResult result = printDialog1.ShowDialog();
if (result == DialogResult.OK)
{
pDoc.PrinterSettings.PrinterName = printDialog1.PrinterSettings.PrinterName;
pDoc.Print();
}
...
This is driving me crazy, and I can't see anything else that would interfere with it.