PageSetupDialog クラス

定義

余白や用紙方向など、ページ関連の印刷設定をユーザーが変更できるようにします。 このクラスは継承できません。

public ref class PageSetupDialog sealed : System::Windows::Forms::CommonDialog
public sealed class PageSetupDialog : System.Windows.Forms.CommonDialog
type PageSetupDialog = class
    inherit CommonDialog
Public NotInheritable Class PageSetupDialog
Inherits CommonDialog
継承

次のコード例では、 プロパティPrinterSettingsPageSetupDialog、および ShowNetwork プロパティの使用をPageSettings示します。 この例を実行するには、 という名前の 、ListBox、 という名前Button1ListBox1の を含むButtonフォームにPageSetupDialog配置しますPageSetupDialog1。 この例では、ボタンのクリック イベントがイベント処理メソッドに接続されていることを確認します。

//This method displays a PageSetupDialog object. If the
// user clicks OK in the dialog, selected results of
// the dialog are displayed in ListBox1.
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   
   // Initialize the dialog's PrinterSettings property to hold user
   // defined printer settings.
   PageSetupDialog1->PageSettings = gcnew System::Drawing::Printing::PageSettings;
   
   // Initialize dialog's PrinterSettings property to hold user
   // set printer settings.
   PageSetupDialog1->PrinterSettings = gcnew System::Drawing::Printing::PrinterSettings;
   
   //Do not show the network in the printer dialog.
   PageSetupDialog1->ShowNetwork = false;
   
   //Show the dialog storing the result.
   System::Windows::Forms::DialogResult result = PageSetupDialog1->ShowDialog();
   
   // If the result is OK, display selected settings in
   // ListBox1. These values can be used when printing the
   // document.
   if ( result == ::DialogResult::OK )
   {
      array<Object^>^results = {PageSetupDialog1->PageSettings->Margins,PageSetupDialog1->PageSettings->PaperSize,PageSetupDialog1->PageSettings->Landscape,PageSetupDialog1->PrinterSettings->PrinterName,PageSetupDialog1->PrinterSettings->PrintRange};
      ListBox1->Items->AddRange( results );
   }
   
}

//This method displays a PageSetupDialog object. If the
// user clicks OK in the dialog, selected results of
// the dialog are displayed in ListBox1.
private void Button1_Click(System.Object sender, System.EventArgs e)
{

    // Initialize the dialog's PrinterSettings property to hold user
    // defined printer settings.
    PageSetupDialog1.PageSettings =
        new System.Drawing.Printing.PageSettings();

    // Initialize dialog's PrinterSettings property to hold user
    // set printer settings.
    PageSetupDialog1.PrinterSettings =
        new System.Drawing.Printing.PrinterSettings();

    //Do not show the network in the printer dialog.
    PageSetupDialog1.ShowNetwork = false;

    //Show the dialog storing the result.
    DialogResult result = PageSetupDialog1.ShowDialog();

    // If the result is OK, display selected settings in
    // ListBox1. These values can be used when printing the
    // document.
    if (result == DialogResult.OK)
    {
        object[] results = new object[]{ 
            PageSetupDialog1.PageSettings.Margins, 
            PageSetupDialog1.PageSettings.PaperSize, 
            PageSetupDialog1.PageSettings.Landscape, 
            PageSetupDialog1.PrinterSettings.PrinterName, 
            PageSetupDialog1.PrinterSettings.PrintRange};
        ListBox1.Items.AddRange(results);
    }
}

'This method displays a PageSetupDialog object. If the
' user clicks OK in the dialog, selected results of
' the dialog are displayed in ListBox1.
Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click

    ' Initialize the dialog's PrinterSettings property to hold user
    ' defined printer settings.
    PageSetupDialog1.PageSettings = _
        New System.Drawing.Printing.PageSettings

    ' Initialize dialog's PrinterSettings property to hold user
    ' set printer settings.
    PageSetupDialog1.PrinterSettings = _
        New System.Drawing.Printing.PrinterSettings

    'Do not show the network in the printer dialog.
    PageSetupDialog1.ShowNetwork = False

    'Show the dialog storing the result.
    Dim result As DialogResult = PageSetupDialog1.ShowDialog()

    ' If the result is OK, display selected settings in
    ' ListBox1. These values can be used when printing the
    ' document.
    If (result = DialogResult.OK) Then
        Dim results() As Object = New Object() _
            {PageSetupDialog1.PageSettings.Margins, _
             PageSetupDialog1.PageSettings.PaperSize, _
             PageSetupDialog1.PageSettings.Landscape, _
             PageSetupDialog1.PrinterSettings.PrinterName, _
             PageSetupDialog1.PrinterSettings.PrintRange}
        ListBox1.Items.AddRange(results)
    End If

End Sub

注釈

ダイアログ ボックスはPageSetupDialog、指定Documentされた の PageSettings 情報と PrinterSettings 情報を変更します。 ユーザーは、ダイアログ ボックスのセクションを有効にして、印刷と余白を操作できます。用紙の向き、サイズ、ソース。と を使用して、ヘルプボタンとネットワーク ボタンを表示します。 プロパティは MinMargins 、ユーザーが選択できる最小余白を定義します。

クラスの PageSetupDialog インスタンスを作成すると、読み取り/書き込みプロパティは初期値に設定されます。 これらの値の一覧については、 コンストラクターを PageSetupDialog 参照してください。

PageSetupDialog表示するにはページ設定が必要なので、 を呼び出すShowDialog前に 、PrinterSettings、または PageSettings プロパティを設定Documentする必要があります。それ以外の場合は例外が発生します。

コンストラクター

PageSetupDialog()

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

プロパティ

AllowMargins

ダイアログ ボックスの余白セクションが有効かどうかを表す値を取得または設定します。

AllowOrientation

ダイアログ ボックスの用紙方向セクション (横向きまたは縦向き) が有効かどうかを表す値を取得または設定します。

AllowPaper

ダイアログ ボックスの用紙セクション (用紙サイズと給紙方法) が有効かどうかを表す値を取得または設定します。

AllowPrinter

[印刷] ボタンが有効かどうかを示す値を取得または設定します。

CanRaiseEvents

コンポーネントがイベントを発生させることがきるかどうかを示す値を取得します。

(継承元 Component)
Container

IContainer を含む Component を取得します。

(継承元 Component)
DesignMode

Component が現在デザイン モードかどうかを示す値を取得します。

(継承元 Component)
Document

ページ設定を取得する対象の PrintDocument を示す値を取得または設定します。

EnableMetric

余白設定がミリメートルで表示されているときに、自動的に 100 分の 1 インチに変換されなければならないかどうかを示す値を取得または設定します。

Events

Component に結び付けられているイベント ハンドラーのリストを取得します。

(継承元 Component)
MinMargins

ユーザーが選択できる余白の最小値 (1/100 インチ単位) を取得または設定します。

PageSettings

変更する対象のページ設定を示す値を取得または設定します。

PrinterSettings

ダイアログ ボックスの [プリンター] ボタンがクリックされた場合に変更するプリンター設定を取得または設定します。

ShowHelp

[ヘルプ] ボタンを表示するかどうかを示す値を取得または設定します。

ShowNetwork

[ネットワーク] ボタンを表示するかどうかを示す値を取得または設定します。

Site

ComponentISite を取得または設定します。

(継承元 Component)
Tag

コントロールに関するデータを格納するオブジェクトを取得または設定します。

(継承元 CommonDialog)

メソッド

CreateObjRef(Type)

リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。

(継承元 MarshalByRefObject)
Dispose()

Component によって使用されているすべてのリソースを解放します。

(継承元 Component)
Dispose(Boolean)

Component によって使用されているアンマネージド リソースを解放し、オプションでマネージド リソースも解放します。

(継承元 Component)
Equals(Object)

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

(継承元 Object)
GetHashCode()

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

(継承元 Object)
GetLifetimeService()
古い.

対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
GetService(Type)

Component またはその Container で提供されるサービスを表すオブジェクトを返します。

(継承元 Component)
GetType()

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

(継承元 Object)
HookProc(IntPtr, Int32, IntPtr, IntPtr)

コモン ダイアログ ボックスに特定の機能を追加するためにオーバーライドされる、コモン ダイアログ ボックスのフック プロシージャを定義します。

(継承元 CommonDialog)
InitializeLifetimeService()
古い.

このインスタンスの有効期間ポリシーを制御する有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
MemberwiseClone()

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

(継承元 Object)
MemberwiseClone(Boolean)

現在の MarshalByRefObject オブジェクトの簡易コピーを作成します。

(継承元 MarshalByRefObject)
OnHelpRequest(EventArgs)

HelpRequest イベントを発生させます。

(継承元 CommonDialog)
OwnerWndProc(IntPtr, Int32, IntPtr, IntPtr)

コモン ダイアログ ボックスに特定の機能を追加するためにオーバーライドされる、オーナー ウィンドウ プロシージャを定義します。

(継承元 CommonDialog)
Reset()

すべてのオプションを既定値にリセットします。

RunDialog(IntPtr)

派生クラスでオーバーライドされるときに、コモン ダイアログ ボックスを指定します。

(継承元 CommonDialog)
ShowDialog()

既定のオーナーを使用してコモン ダイアログ ボックスを実行します。

(継承元 CommonDialog)
ShowDialog(IWin32Window)

指定したオーナーを使用してコモン ダイアログ ボックスを実行します。

(継承元 CommonDialog)
ToString()

Component の名前 (存在する場合) を格納する String を返します。 このメソッドはオーバーライドできません。

(継承元 Component)

イベント

Disposed

Dispose() メソッドの呼び出しによってコンポーネントが破棄されるときに発生します。

(継承元 Component)
HelpRequest

ユーザーがコモン ダイアログ ボックスの [?] ボタンをクリックすると発生します。

(継承元 CommonDialog)

適用対象

こちらもご覧ください