在我的 C# 应用程序中,我试图生成打印预览,但屏幕上没有出现进度对话框。
我相信您可以在实际打印(即不是打印预览)时使用PrintDocument.PrintController来防止这种情况发生,但是在执行打印预览时它似乎不起作用。
我的代码如下:
public FrmDeliveryNotePrintPreview(DeliveryNote deliveryNote)
{
InitializeComponent();
this.Text = "Delivery Note #" + deliveryNote.Id.ToString();
// The print preview window should occupy about 90% of the
// total screen height
int height = (int) (Screen.PrimaryScreen.Bounds.Height * 0.9);
// Making an assumption that we are printing to A4 landscape,
// then adjust the width to give the correct height:width ratio
// for A4 landscape.
int width = (int) (height / 1.415);
// Set the bounds of this form. The PrintPreviewControl is
// docked, so it should just do the right thing
this.SetBounds(0, 0, width, height);
PrinterSettings printerSettings = new PrinterSettings();
PrintDeliveryNotes pdn = new PrintDeliveryNotes(
new DeliveryNote[] { deliveryNote },
printerSettings);
PrintDocument printDocument = pdn.PrintDocument;
printDocument.PrintController = new PreviewPrintController();
ppcDeliveryNote.Document = printDocument;
}
除了显示打印预览进度对话框之外,打印预览完全按照我的意愿工作。
请问有什么建议吗?