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; } }
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(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)