私の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;
}
印刷プレビューの進行状況ダイアログが表示されることを除けば、印刷プレビューは希望どおりに機能します。
提案をお願いします?