20點想問下c# printpreviewdialog 同p

2011-06-07 11:30 pm
用左printdocument 同 printpreivewdialog咁點可以多頁打印..
現在只能打印當前頁...
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{

int temp=1;//設置系數格行距離
e.Graphics.DrawString("大東物業", new Font("宋體", 30), Brushes.Black, 100, 80);//設置標題
e.Graphics.DrawString("樓宇/大廈", new Font("宋體", 15), Brushes.Black, 100, 145);//設置標題
e.Graphics.DrawString("座數", new Font("宋體", 15), Brushes.Black, 250, 145);
e.Graphics.DrawString("樓層", new Font("宋體", 15), Brushes.Black, 350, 145);
e.Graphics.DrawString("單位", new Font("宋體", 15), Brushes.Black, 450, 145);
e.Graphics.DrawString("售價", new Font("宋體", 15), Brushes.Black, 550, 145);
e.Graphics.DrawString("租金", new Font("宋體", 15), Brushes.Black, 650, 145);
for (int i = 0; i < dataGridView1.RowCount ; i++)
{

if ((bool)dataGridView1.Rows[i].Cells[0].EditedFormattedValue == true)
{
e.Graphics.DrawString(dataGridView1.Rows[i].Cells["garden"].Value.ToString(), new Font("宋體", 15), Brushes.Black, 100, 160+temp*30);
e.Graphics.DrawString(dataGridView1.Rows[i].Cells["block"].Value.ToString(), new Font("宋體", 15), Brushes.Black, 250, 160 + temp * 30);
e.Graphics.DrawString(dataGridView1.Rows[i].Cells["floor"].Value.ToString(), new Font("宋體", 15), Brushes.Black, 350, 160 + temp * 30);
e.Graphics.DrawString(dataGridView1.Rows[i].Cells["unit"].Value.ToString(), new Font("宋體", 15), Brushes.Black, 450, 160 + temp * 30);
e.Graphics.DrawString(dataGridView1.Rows[i].Cells["sellprice"].Value.ToString(), new Font("宋體", 15), Brushes.Black, 550, 160 + temp * 30);
e.Graphics.DrawString(dataGridView1.Rows[i].Cells["rentprice"].Value.ToString(), new Font("宋體", 15), Brushes.Black, 650, 160 + temp * 30);
temp++;

}
}
}

private void button6_Click(object sender, EventArgs e)
{
//開啟操作係統的防鋸齒功能
this.printPreviewDialog1.UseAntiAlias = true;
//設置預覽的文檔
this.printPreviewDialog1.Document = this.printDocument1;
//打開預覽的窗口
printPreviewDialog1.ShowDialog();

}

回答 (2)

2011-06-08 5:47 pm
✔ 最佳答案
你只需要係將 e.HasMorePages 設定為 true 就可以印多過一頁
2011-06-08 12:47 am
大佬..我唔係想買3wo.. 點比分你呀~


收錄日期: 2021-04-13 18:02:09
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20110607000051KK00417

檢視 Wayback Machine 備份