views:

1081

answers:

2

An in house application that I'm developing is behaving strange on a Windows 7 (64 bit) PC.

If I create an instance of a PrintDialog, and call it's ShowDialog() method, the method immediately returns DialogResult.Cancel without showing the printer dialog form.

The Windows 7 PC does have printers installed (with a working default printer).

        PrintDialog printDialog = new PrintDialog();
        printDialog.PrinterSettings.Copies = 2;
        printDialog.AllowCurrentPage = false;
        printDialog.AllowPrintToFile = false;
        printDialog.AllowSelection = false;
        printDialog.AllowSomePages = false;
        DialogResult dialogResult = printDialog.ShowDialog(this);
        if (dialogResult == DialogResult.Cancel)
            return;

Any clues why this is happening?

+7  A: 

Set UseEXDialog to true to work around this bug.

Stefan Schultze
Sounds like a good tip, but do you have a reference?
Henk Holterman
Thanks, For anyone else interested, the MSDN article for UseExDialog has more comments about this - http://msdn.microsoft.com/en-us/library/system.windows.forms.printdialog.useexdialog.aspx
Bryan
My initial googling didn't find anything useful, however now that I know the solution, there is plenty of reading material on this issue http://www.google.co.uk/search?q=UseExDialog+cancelled
Bryan
A: 

Thank you, that worked

Andy