C#Winform中打印预览时设置横向打印

PrintDocument的打印相关的方法被调用的顺序是这样的:
QueryPageSettings
StartPage
PrintPage
EndPage
目前只处理了StartPage和PrintPage。 于是加上了QueryPageSettings事件的处理,发现每次执行打印时 QueryPageSettingsEventArgs.PageSettings.Landscape仍然为false,
虽然前面设置了 DefaultpageSettings.Landscape=true。
于是在此事件中将其指定为true,再次预览时,终于可以横向看到排列整齐的报表了。
private void button2_Click(object sender, EventArgs e) {
PrintPreviewDialog pd = new PrintPreviewDialog();
pd.Document = new PrintDocument();
pd.Document.PrintPage += new PrintPageEventHandler(Document_PrintPage);
pd.Document.QueryPageSettings += new QueryPageSettingsEventHandler(Document_QueryPageSettings); pd.Document.BeginPrint += new PrintEventHandler(Document_BeginPrint); if (pd.ShowDialog(this) == DialogResult.OK)
{
}
}
void Document_QueryPageSettings (object sender, QueryPageSettingsEventArgs e)
{
e.PageSettings.Landscape = true;
int index = -1;
for (int i=0;i

Original: https://blog.csdn.net/u013400314/article/details/127654791
Author: Ares-Wang
Title: C#Winform中打印预览时设置横向打印

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/712725/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球