Click here to Skip to main content
15,908,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use printDocument and pageSetupDialog. How do I change the paper size when I select size from pageSetupDialog?

What I have tried:

private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {

Updated 27-Oct-23 7:16am

Share this answer
Where am i wrong? When i select the paper size it doesn't change the size in the document

pageSetupDialog1->PageSettings = gcnew System::Drawing::Printing::PageSettings;
	pageSetupDialog1->PrinterSettings = gcnew System::Drawing::Printing::PrinterSettings;
	pageSetupDialog1->ShowNetwork = false;
	System::Windows::Forms::DialogResult result = pageSetupDialog1->ShowDialog();
	if (result == System::Windows::Forms::DialogResult::OK)
		printDocument1->DefaultPageSettings->PaperSize = pageSetupDialog1->PageSettings->PaperSize;
Share this answer
Richard MacCutchan 28-Oct-23 7:18am    
Sorry, I have no idea what the problem may be; my tests change the paper size correctly in the printer dialog. You need to use the debugger to find out exactly what is going wrong.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900