怎样让打印机打印出TAB(\T),在线等

wgsasd311 2008-08-04 11:40:25
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;

linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics);

//开始打印标题(占两行)
ev.Graphics.DrawString(title, printFont, Brushes.Black, leftMargin, topMargin, new StringFormat());
count = 2;
//打印内容
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;
}
当LINE中有"\t"是打印机会忽列,怎样让打印机遇到"\t"是跳到下一列打印?
如解决,立马结贴(本人在线等).
...全文
240 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wgsasd311 2008-08-04
  • 打赏
  • 举报
回复
谢谢您的回复!
我是初学C#,您能直接告诉我上面一段代码该怎么改吗?
rainxy2000 2008-08-04
  • 打赏
  • 举报
回复
用TextFormatFlags.ExpandTabs来描述TextFormat

private void RenderText6(PaintEventArgs e)
{
TextFormatFlags flags = TextFormatFlags.Bottom | TextFormatFlags.ExpandTabs;
TextRenderer.DrawText(e.Graphics, "This is some text that will be clipped at the end.", this.Font,
new Rectangle(10, 10, 100, 50), SystemColors.ControlText, flags);
}

wgsasd311 2008-08-04
  • 打赏
  • 举报
回复
up
wgsasd311 2008-08-04
  • 打赏
  • 举报
回复

110,502

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧