PrintDocument 打印richtextbox 里面的内容的时候 行超越过纸张 请问如何解决 我的richtextbox读入的是xml文件,打印时候行的字数超越过纸张(A4) 我是第一次用PrintDocument 请问如何设置 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.webmis.com.cn/DownLoad/PrinterPageSetting.rar private void pd_PrintPage(object sender, PrintPageEventArgs ev) { float linesPerPage = 0; float yPos = 0; int count = 0; float leftMargin = ev.MarginBounds.Left; float topMargin = ev.MarginBounds.Top; string line = null; // Calculate the number of lines per page. linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics); // Print each line of the file. while(count < linesPerPage && ((line=streamToPrint.ReadLine()) != null)) { yPos = topMargin + (count * printFont.GetHeight(ev.Graphics)); ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, new StringFormat()); count++; } // If more lines exist, print another page. if(line != null) ev.HasMorePages = true; else ev.HasMorePages = false; } 如何获取CPU唯一标识?? gridview 多条件查询问题 求助用c#怎么创建filesystemobject对象. 图片转移的问题 急!用 C#实现循环得到页面元素内容 Developer Express控件组合中的GridControl控件,如何设置其中一行的背景颜色? 什么是委托? 怎么处理“任务计划” 求点击一下按钮就新增一个TextBox的例子 求解 WinForm程序连Oracle乱码的问题 Mother of all Visual Studio 2005 RTM bugs
{
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
string line = null; // Calculate the number of lines per page.
linesPerPage = ev.MarginBounds.Height /
printFont.GetHeight(ev.Graphics); // Print each line of the file.
while(count < linesPerPage &&
((line=streamToPrint.ReadLine()) != null))
{
yPos = topMargin + (count *
printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString(line, printFont, Brushes.Black,
leftMargin, yPos, new StringFormat());
count++;
} // If more lines exist, print another page.
if(line != null)
ev.HasMorePages = true;
else
ev.HasMorePages = false;
}