Windows Develop Bookmark and Share   
 index > Windows Forms General > PageSetupDialog problem - PaperSize selection stops working after opening the dialog multiple times and choosing various sizes
 

PageSetupDialog problem - PaperSize selection stops working after opening the dialog multiple times and choosing various sizes

I am running into an issue working with the PageSetupDialog.
I have some fairly simple code (below) that instantiates a PageSetupDialog, assigns a local PrintDocument member variable (which is used to retain the current page setup settings).

If I repeat the following steps over and over:
  1) open the PageSetupDialog, 2) choose a different Paper Size, and 3) press [OK]
...the first few times I do this, each time I reopen the PageSetupDialog, things appear to be ok, and it does reflect the most recent Paper Size selection.  But if I continue to repeat these steps -- eventually, the PaperSize stops working correctly (e.g. it defaults to Letter when the PageSetupDialog opens, and if I try to choose a different Paper Size and press OK, the underlying m_printDocument.DefaultPageSettings.PaperSize does not reflect the new selection).

I have tried this and run into the same issue with 2 different printers (use "Control Panel > Printers" to set the default printer before running the app).

I have a simple form with a button on it, and the following code:

  private void button1_Click(object sender, EventArgs e)
  {
   PageSetupDialog pageSetupDialog = new PageSetupDialog();
   pageSetupDialog.Document = m_printDocument;
   pageSetupDialog.ShowDialog();
  }

  private PrintDocument m_printDocument = new PrintDocument();

This seems to be a bug.  Am I not doing things correctly?

Thanks in advance for any assisntance,
Rob

Rgur  Friday, October 02, 2009 7:03 PM
A bit more info.  Seems this only happens on some printers -- I can get it to happen for two HP's ("HP Designjet Z6100 42in Photo HPGL2", and "HP LaserJet P2015 Series PS").  You can download the driver for the "HP Designjet Z6100" here if you want to try it for yourself.
http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareDescription.jsp?lang=en&cc=us&prodTypeId=18972&prodSeriesId=3338748&prodNameId=3338749&swEnvOID=228&swLang=8&mode=2&taskId=135&swItem=pl-51433-4

Pick size "A0" and it gets flaky.  Pick sizes "Arch D", "Arch E", and it works ok.

To rule out the drivers as being problematic, I do not see the problem in Notepad (doing the same "pagesetup & pick paper size" steps there).

So, does seem like a bug, just a bit tricky to encounter.

Rob.
Rgur  Friday, October 02, 2009 9:17 PM
It might be a bug.  Look on Connect for a workaround or use your own.  Try WPF, the current printing platform.
JohnWein  Friday, October 02, 2009 9:28 PM
Hi Rob,

Thank you for your valuable feedback. I can reproduce the issue on my side. Here are the details of my test.

1. If you do not select “16k XXX cross XXX mm ” and “8k XXX cross XXX mm ” paper size, it always works properly.

2. If you select “16k XXX cross XXX mm” or “8k XXX cross XXX mm” paper size, it will show “Letter” for the size field next time you open the PageSetupDialog and m_printDocument.DefaultPageSettings.PaperSize.PaperName keeps showing "custom".

This problem has been raised and accepted by Connect engineer. We have not found a proper workaround now. Sorry for the inconvenience.
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=473597

Could you please tell me the detail information about your application? That can let me to find a temporary solution for you.

I am waiting for your reply.

Sincerely,
Kira Qian
Send us any feedback you have about the help from MSFT at EMAIL REMOVED
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework!
Kira Qian  Tuesday, October 06, 2009 5:38 AM
Hi Kira,

Thanks very much for following up.

I had raised a support incident with Microsoft yesterday prior to your posting, and a support person has contacted me and is actively working on this.

As far as details about my app -- the behavior is consistent with what you would see in other windows applications e.g. NotePad. 
User opens the page-setup dialog, chooses a paper size and presses OK.
Our app retains that paper size for the session, and uses it the next time the user prints.
If the user re-opens the page-setup dialog, the "current" paper size should be shown.

Thanks,
Rob.
Rgur  Tuesday, October 06, 2009 6:02 PM

You can use google to search for other answers

Custom Search

More Threads

• Autocomplete on ComboBox in VS 2003?
• How to speed up datagridview
• How to do a new line return on a rich text field
• Tab Control
• Splash screen and Main form refresh problem
• Showdialog issue
• ExecWB in the managed WebBrowser object
• threading.timer and databinding
• Error while canceling print: "startdocprinter call was not issued"
• TabControl: Custom TabPageCollection?