Form1.cs 926 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace WindowsFormsPrintDialog
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. private void button1_Click(object sender, EventArgs e)
  19. {
  20. printDialog1.Document = printDocument1;
  21. //启用"打印到文件"复选框
  22. printDialog1.AllowPrintToFile = true;
  23. //显示“当前项”按钮
  24. printDialog1.AllowCurrentPage = true;
  25. //启用"选择按钮",选择范围
  26. printDialog1.AllowSelection = true;
  27. //启用"页"按钮
  28. printDialog1.AllowSomePages = true;
  29. printDialog1.ShowDialog();
  30. }
  31. }
  32. }