Click here to Skip to main content
11,478,066 members (73,130 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Hello,

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

I have this code in pagesetupdialog

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

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 14-Nov-12 1:17am

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 184
1 OriginalGriff 160
2 Frankie-C 160
3 Sascha Lefèvre 145
4 F-ES Sitecore 120
0 Sergey Alexandrovich Kryukov 7,675
1 OriginalGriff 7,256
2 Sascha Lefèvre 3,034
3 Maciej Los 2,491
4 Richard Deeming 2,305


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100