當在我的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;
}
打印預覽作品完全一樣我想,除了顯示的打印預覽進度對話框中的事實。
請提出建議?
PrintDeliveryNotes是打印交貨單數組的類。不過,在這種情況下,我並沒有調用Print()方法,而是簡單地檢索PrintDocument屬性並將其提供給自定義表單上的PrintPreviewControl。 – Bryan 2009-08-31 14:40:38