回复 1楼mindrayguowei的帖子
需要自定义 打印预览 对话框,测试代码如下:
- private int currentPage = 1;
- private int lastPage = 1;
- private void Form1_Load(object sender, EventArgs e)
- {
- PrintDocument pd = new PrintDocument();
- PrintPreviewDialog pview = new PrintPreviewDialog();
- pd.DocumentName = "Name"; // anything you want here
- lastPage = tx.Pages;
- pd.PrintPage += new PrintPageEventHandler(OnPrintPage);
- pd.PrinterSettings.MinimumPage = 1;
- pd.PrinterSettings.MaximumPage = lastPage;
- pd.PrinterSettings.FromPage = 1;
- pd.PrinterSettings.ToPage = lastPage;
- pview.UseAntiAlias = true;
- pview.Document = pd;
- pview.ShowInTaskbar = true;
- pview.WindowState = FormWindowState.Maximized;
- pview.Show();
- }
- private void OnPrintPage(object sender, PrintPageEventArgs ppe)
- {
- tx.Print(currentPage, ppe);
- currentPage++;
- if (currentPage <= lastPage)
- ppe.HasMorePages = true;
- else
- currentPage = 1;
- }
复制代码 |