タイトル : ページ設定ダイアログボックスの設定 投稿日 : 2008/02/08(Fri) 14:01 投稿者 : ひでと
お世話になります。 ページ設定ダイアログを表示し、余白を設定して印刷をしようとしています。 実際に印刷すると右下方向にずれてしまいます。 ダイアログボックスの余白をすべて10mmにすると、左上が15,15に印刷されてしまいます。 どこが悪いのでしょうか? Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click PrintDocument1.Print() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim PrnSet As New Printing.PrinterSettings Dim PapSet As New Printing.PageSettings Dim Ret As DialogResult PrintDialog1.PrinterSettings = New Printing.PrinterSettings With PrintDialog1 .UseEXDialog = False .AllowSelection = False End With Ret = PrintDialog1.ShowDialog() PrnSet = PrintDialog1.PrinterSettings If Ret = Windows.Forms.DialogResult.OK Then PrnSet = PrintDialog1.PrinterSettings PrintDocument1.PrinterSettings = PrnSet PageSetupDialog1.PageSettings = New Printing.PageSettings With PageSetupDialog1.PageSettings .PaperSize = PrnSet.DefaultPageSettings.PaperSize .Landscape = PrnSet.DefaultPageSettings.Landscape .Margins = PrnSet.DefaultPageSettings.Margins End With Ret = PageSetupDialog1.ShowDialog If Ret = Windows.Forms.DialogResult.OK Then PapSet = PageSetupDialog1.PageSettings PrintDocument1.DefaultPageSettings = PapSet End Sub Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage e.Graphics.DrawLine(New Pen(Color.Black, 0), _ e.MarginBounds.Left, e.MarginBounds.Top, _ e.MarginBounds.Right, e.MarginBounds.Top) e.Graphics.DrawLine(New Pen(Color.Black, 0), _ e.MarginBounds.Left, e.MarginBounds.Bottom, _ e.MarginBounds.Right, e.MarginBounds.Bottom) e.Graphics.DrawLine(New Pen(Color.Black, 0), _ e.MarginBounds.Left, e.MarginBounds.Top, _ e.MarginBounds.Left, e.MarginBounds.Bottom) e.Graphics.DrawLine(New Pen(Color.Black, 0), _ e.MarginBounds.Right, e.MarginBounds.Top, _ e.MarginBounds.Right, e.MarginBounds.Bottom) e.HasMorePages = False End Sub |