Form1.cs 1017 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Drawing.Printing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace WindowsFormsPrintPageSetupDialog
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19. private void button1_Click(object sender, EventArgs e)
  20. {
  21. pageSetupDialog1.Document = printDocument1;
  22. //启用边距
  23. this.pageSetupDialog1.AllowMargins = true; //启用边距
  24. this.pageSetupDialog1.AllowOrientation = true; //启用对话框的方向部分
  25. this.pageSetupDialog1.AllowPaper = true; //启用对话框的纸张部分
  26. this.pageSetupDialog1.AllowPrinter = true; //表示打印机的启动按钮
  27. //显示页面设置对话框
  28. this.pageSetupDialog1.ShowDialog();
  29. }
  30. }
  31. }