PrintDialog クラス

定義

ユーザー入力に従って PrintTicket および PrintQueue を構成し、ドキュメントを印刷する標準の Microsoft Windows 印刷ダイアログ ボックスを呼び出します。

public ref class PrintDialog
public class PrintDialog
type PrintDialog = class
Public Class PrintDialog
継承
PrintDialog

次の例は、拡張アプリケーション マークアップ言語 (XAML) マークアップとコードを使用して、インスタンスを作成し、単純な PrintDialog コードを表示する方法を示しています。

<Button Width="200" Click="InvokePrint">Invoke PrintDialog</Button>

...

private void InvokePrint(object sender, RoutedEventArgs e)
    {
        // Create the print dialog object and set options
        PrintDialog pDialog = new PrintDialog();
        pDialog.PageRangeSelection = PageRangeSelection.AllPages;
        pDialog.UserPageRangeEnabled = true;

        // Display the dialog. This returns true if the user presses the Print button.
        Nullable<Boolean> print = pDialog.ShowDialog();
        if (print == true)
        {
            XpsDocument xpsDocument = new XpsDocument("C:\\FixedDocumentSequence.xps", FileAccess.ReadWrite);
            FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
            pDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job");
        }
    }
Private Sub InvokePrint(ByVal sender As Object, ByVal e As RoutedEventArgs)
        ' Create the print dialog object and set options
        Dim pDialog As New PrintDialog()
        pDialog.PageRangeSelection = PageRangeSelection.AllPages
        pDialog.UserPageRangeEnabled = True

        ' Display the dialog. This returns true if the user presses the Print button.
        Dim print? As Boolean = pDialog.ShowDialog()
        If print = True Then
            Dim xpsDocument As New XpsDocument("C:\FixedDocumentSequence.xps", FileAccess.ReadWrite)
            Dim fixedDocSeq As FixedDocumentSequence = xpsDocument.GetFixedDocumentSequence()
            pDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job")
        End If
End Sub

注釈

ユーザーは、[ 印刷 ] ダイアログ ボックスを使用してプリンターを選択し、構成し、印刷ジョブを実行できます。

厳密に言うと、ダイアログを開かなくても PrintDocument メソッドを使用できます。 その意味で、コントロールは目に見えない印刷コンポーネントとして使用できます。 ただし、パフォーマンス上の理由から、AddJob メソッド、または XpsDocumentWriter の多くの Write および WriteAsync メソッドのいずれかを使用することをお勧めします。 詳細については、「 方法: XPS ファイルをプログラムで印刷する」を参照してください。

このクラスを混同しないでください。 System.Windows.Controls.PrintDialogSystem.Windows.Forms.PrintDialog 後者は、Windows フォーム アプリケーションで使用されます。 System.Windows.Controls.PrintDialogは、Windows Presentation Foundation アプリケーションで使用されます。

コンストラクター

PrintDialog()

PrintDialog クラスの新しいインスタンスを初期化します。

プロパティ

CurrentPageEnabled

プリンターで現在のページを印刷するためのオプションが有効かどうかを示す値を取得または設定します。

MaxPage

ページ範囲内で許容されている最大のページ番号を取得または設定します。

MinPage

ページ範囲内で許容されている最小のページ番号を取得または設定します。

PageRange

PageRangeSelectionUserPages に設定されている場合に印刷するページの範囲を取得または設定します。

PageRangeSelection

PageRangeSelection のこのインスタンスの PrintDialog を取得または設定します。

PrintableAreaHeight

ページの印刷可能領域の高さを取得します。

PrintableAreaWidth

ページの印刷可能領域の幅を取得します。

PrintQueue

選択されているプリンターを表す PrintQueue を取得または設定します。

PrintTicket

ユーザーが現在の印刷ジョブに対して [印刷] をクリックした場合に、PrintDialog によって使用される PrintTicket を取得または設定します。

SelectedPagesEnabled

プリンターで選択されたページを印刷するためのオプションが有効かどうかを示す値を取得または設定します。

UserPageRangeEnabled

[印刷] ダイアログ ボックスの印刷するページの範囲を指定するオプションを、ユーザーが使用できるかどうかを示す値を取得または設定します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
PrintDocument(DocumentPaginator, String)

現在選択されている DocumentPaginatorPrintQueue オブジェクトを印刷します。

PrintVisual(Visual, String)

Visual クラスから派生している (テキスト以外の) ビジュアル オブジェクトを、現在選択されている PrintQueue に印刷します。

ShowDialog()

PrintDialog を、モーダル ダイアログ ボックスとして呼び出します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象