Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a little problem(or else I wouldnt be asking here :)) with saving pagesetup in pagesetupdialog and then goint to print option which will use those pagestupdialog settings

I have this code in pagesetupdialog

C#
private void btnPageSetup_Click(object sender, EventArgs e)
        {            
            PrintDocument printDocument1 = new PrintDocument();

            printDocument1.PrintPage += new PrintPageEventHandler(this.printDocument1_PrintPage);

            PageSetupDialog pageSetup = new PageSetupDialog();

            pageSetup.Document = printDocument1;

            pageSetup.PageSettings = printDocument1.DefaultPageSettings;
                        
            string strText = "";
            
            foreach (object x in listBox1.Items)
            {                
                strText = strText + x.ToString() + "\n";
            }

            myReader = new StringReader(strText);

            if (pageSetup.ShowDialog() == DialogResult.OK)
            {                
                printDocument1.DefaultPageSettings = pageSetup.PageSettings;
            }
        }


and this also

C#
private void btnPrint_Click(object sender, EventArgs e)
        {            
            printDialog1.Document = printDocument1;

            string strText = "";
            foreach (object x in listBox1.Items)
            {
                strText = strText + x.ToString() + "\n";
            }

            myReader = new StringReader(strText);
            if (printDialog1.ShowDialog() == DialogResult.OK)
            {
                this.printDocument1.Print();
            }

        }


so I need to to print document based on pagesetupdialog settings, but I am missing something
Posted

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