Click here to Skip to main content
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 0:17am

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

  Print Answers RSS
0 CHill60 280
1 Sarvesh Kumar Gupta 238
2 Sergey Alexandrovich Kryukov 203
3 OriginalGriff 163
4 DamithSL 153


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