找回密码
 立即注册

QQ登录

只需一步,快速开始

sky123

注册会员

1

主题

2

帖子

19

积分

注册会员

积分
19
最新发帖
sky123
注册会员   /  发表于:2017-10-25 21:47  /   查看:3322  /  回复:3
MultiRow 打印时得调用PageSetup方法,打开页面设置纸张、打印方向和页边距。
我想是否可以通过代码设置好这些内容,而不需要每一次都调用PageSetup方法打开设置窗口来设置。

3 个回复

倒序浏览
sky123
注册会员   /  发表于:2017-10-26 07:32:52
沙发
求大神指点
回复 使用道具 举报
robert
金牌服务用户   /  发表于:2017-11-1 15:35:53
板凳
  1.             var printDocument = new System.Drawing.Printing.PrintDocument();
  2.             PaperSize a4Paper = null;
  3.             for (int i = 0; i < printDocument.PrinterSettings.PaperSizes.Count; i++)
  4.             {
  5.                 if(printDocument.PrinterSettings.PaperSizes[i].Kind == PaperKind.A4)
  6.                 {
  7.                     a4Paper = printDocument.PrinterSettings.PaperSizes[i];
  8.                     break;
  9.                 }
  10.             }
  11.             printDocument.DefaultPageSettings.PaperSize = a4Paper;
  12.             printDocument.DefaultPageSettings.Landscape = false;

  13.             gcMultiRow1.Document = printDocument;
复制代码
回复 使用道具 举报
robert
金牌服务用户   /  发表于:2017-11-1 15:37:20
地板
核心代码就是
  1.             var printDocument = new System.Drawing.Printing.PrintDocument();

  2.             // 设置printDocument.DefaultPageSettings 属性
  3.             printDocument.DefaultPageSettings.Landscape = false;

  4.             gcMultiRow1.Document = printDocument;
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部