VB.NET, C#, PowerShellを使用しているエンジニアのためのサイト。
基本的な使用方法から開発で役立つTipsまで幅広く取り扱っています。
PrintDialogの[ページ範囲]欄には、「すべて」「選択した部分」「現在のページ」「ページ指定」の項目がありますが、デフォルトでは「すべて」以外は無効状態となっており選択することができません。
下記プロパティをtrueにすることで有効にすることができます。
項目 | プロパティ |
---|---|
選択した部分 | AllowSelection |
現在のページ | AllowCurrentPage |
ページ指定 | AllowSomePages |
private void button1_Click(object sender, EventArgs e) { System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings(); // プリンタ設定情報をダイアログにセット printDialog1.PrinterSettings = ps; // 選択した部分 printDialog1.AllowSelection = true; // 現在のページ printDialog1.AllowCurrentPage = true; // ページ指定 printDialog1.AllowSomePages = true; // PrintDialogを表示する if (printDialog1.ShowDialog() == DialogResult.OK) { } }