tagCANDY CGI VBレスキュー(花ちゃん) の Visual Basic 2010 用 掲示板(VB.NET 掲示板)
VBレスキュー(花ちゃん) の Visual Basic 2010 用 掲示板(VB.NET 掲示板)
[ツリー表示へ]  [ワード検索]  [Home]

タイトル Re^2: 印刷で用紙の横向きと縦向きをきりかえる
投稿日: 2008/03/06(Thu) 13:30
投稿者ひでと
ありがとうございます。
下の魔界の仮面弁士様のご指摘のように ページ毎に向きを切り替えて印刷
したいと思っています。はじめに乗せたものを直してふたたび乗せます。
1ページ目は用紙の向きを縦に2ページ目は横にしてプレビューしようとしております。
Public Class Form1
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Ret As DialogResult
        PrintPreviewDialog1.Document = Me.PrintDocument1
        Ret = PrintPreviewDialog1.ShowDialog()
    End Sub
    Private Sub PageSetting1(ByVal sender As Object, ByRef e As System.Drawing.Printing.PrintPageEventArgs)
        'Dim sender As New System.Drawing.Printing.PrintDocument
        '通常使うプリンターのPageSettingsを取得
        Dim dftPSettings As New System.Drawing.Printing.PageSettings
        'dftPSettings = sender.PrinterSettings.DefaultPageSettings
        dftPSettings.Landscape = False
        With e.PageSettings
            .Landscape = False
            .Margins.Left = 20 * 39.37 / 10 - dftPSettings.HardMarginX
            .Margins.Right = 10 * 39.37 / 10 - dftPSettings.HardMarginX
            .Margins.Top = 10 * 39.37 / 10 - dftPSettings.HardMarginY
            .Margins.Bottom = 10 * 39.37 / 10 - dftPSettings.HardMarginY
        End With
    End Sub
    Private Sub PageSetting2(ByVal sender As Object, ByRef e As System.Drawing.Printing.PrintPageEventArgs)
        'Dim sender As New System.Drawing.Printing.PrintDocument
        '通常使うプリンターのPageSettingsを取得
        Dim dftPSettings As New System.Drawing.Printing.PageSettings
        'dftPSettings = sender.PrinterSettings.DefaultPageSettings
        dftPSettings.Landscape = True
        With e.PageSettings
            .Landscape = True
            .Margins.Left = 10 * 39.37 / 10 - dftPSettings.HardMarginX
            .Margins.Right = 10 * 39.37 / 10 - dftPSettings.HardMarginX
            .Margins.Top = 20 * 39.37 / 10 - dftPSettings.HardMarginY
            .Margins.Bottom = 10 * 39.37 / 10 - dftPSettings.HardMarginY
        End With
    End Sub
    Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Static Page As Integer
        Dim nFont As Font
        nFont = New Font("MS 明朝", 10)
        If Page = 0 Then
            PageSetting1(sender, e)
            e.Graphics.DrawString("ページ1", nFont, Brushes.Black, _
                e.PageSettings.Margins.Left + 10, e.PageSettings.Margins.Top + 10)
            e.HasMorePages = True
            Page = 1
        Else
            PageSetting2(sender, e)
            e.Graphics.DrawString("ページ2", nFont, Brushes.Black, _
               e.PageSettings.Margins.Left + 10, e.PageSettings.Margins.Top + 10)
            e.HasMorePages = False
        End If
    End Sub
End Class

- 関連一覧ツリー をクリックするとツリー全体を一括表示します)

古いスレッドにレスはつけられません。