PrintDialog orientation bug ?

E

Emmanuel

Hi,

the PrintDialog does not return the correct value for the Orientation of
the page if it is first initialized to false.

The following code demonstrates the problem:

PrintDialog pdlg = new PrintDialog();
pdlg.PrinterSettings = new System.Drawing.Printing.PrinterSettings();

// If this line is omitted everything works fine.
pdlg.PrinterSettings.DefaultPageSettings.Landscape = false;

if( pdlg.ShowDialog() == DialogResult.OK )
MessageBox.Show("Landscape is " +
pdlg.PrinterSettings.DefaultPageSettings.Landscape.ToString(),
"Info",
MessageBoxButtons.OK,
MessageBoxIcon.Information );

If the initialization of the orientation is omitted the PrintDialog works
fine returning the correct value for the orientation.

Is this a bug or am I doing something wrong ?

I want to be able to setup the default settings in the dialog (Printer
properties), show the dialog and then get the values chosen by the user.

Thanks
Emmanuel
 
J

Jeffrey Tan[MSFT]

Hi Emmanuel,

Currently, we have reproduced out this issue and will do some research in
this issue. We will reply to you ASAP. Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Emmanuel,

Sorry for letting you wait for so long.

I have some research into this issue, and it seems like a bug that we are
not updating the PrinterSettings.DefaultPageSettings when the PrintDialog
is closed.

The recommended way of doing this would be to use PrintDocument. The code
below will unblock you:
private void button1_Click(object sender, EventArgs e)
{
PrintDialog pd = new PrintDialog();
System.Drawing.Printing.PrintDocument doc = new
System.Drawing.Printing.PrintDocument();

pd.Document = doc;
doc.DefaultPageSettings.Landscape = false;

if (pd.ShowDialog() == DialogResult.OK)
{
MessageBox.Show(doc.DefaultPageSettings.Landscape.ToString());
}
}

Please refer to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemWindowsFormsPrintDialogClassTopic.asp for more information on
using PrintDialog.

Also, we have reported this issue to our product team, which tracked this
issue in an internal document. Hope my reply makes sense to you.
======================================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
E

Emmanuel

Thanks Jeffrey.

As I now understand the procedure for setting the default settings of the
PrintDialog control and then get the user values from the PrintDialog is the
following:

//
// Create a private instance of the PrintDocument class in order
// to be able to remember the user settings.
private PrintDocument _PrintDocument = new PrintDocument();

//
// When the user presses the button that will display the PrintDialog...
private void btnPrintDialog_Click(object sender, System.EventArgs e)
{
PrintDialog pdlg = new PrintDialog();
pdlg.Document = _PrintDocument;

if( pdlg.ShowDialog() == DialogResult.OK )
{
// Get the user selected values from the _PrintDocument object.
// For example:
// 1. To get the orientation use the:
// _PrintDocument.DefaultPageSettings.Landscape attribute.
// 2. To get the page range to print use:
// _PrintDocument.PrinterSettings.FromPage (and ToPage)
// etc.
}
}
 
J

Jeffrey Tan[MSFT]

Hi Emmanuel,

Thanks for your feedback.

Yes, we should create a new printdocument class for printdialog to record
the dialog setting for printing. Anyway, if you need any further help,
please feel free to tell me, Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

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

Top