【发布时间】:2012-03-09 17:11:00
【问题描述】:
好的,在我的记事本之类的程序中,我想像代码一样打印文本,所以我希望保留字以蓝色打印,文本在页边距内有什么想法吗? 这是我目前所拥有的。
int charPag = 0;
int linPag = 0;
Font rodFont = new Font("Courier New", (float)10.0);
e.Graphics.MeasureString(stringToPrint, txtMain.Font, e.MarginBounds.Size, StringFormat.GenericTypographic, out charPag, out linPag);
e.Graphics.DrawString(stringToPrint, txtMain.Font, new SolidBrush(Color.Black), e.MarginBounds, StringFormat.GenericTypographic);
stringToPrint = stringToPrint.Substring(charPag);
e.Graphics.DrawLine(Pens.Black, e.MarginBounds.Left, e.MarginBounds.Bottom, e.MarginBounds.Right, e.MarginBounds.Bottom);
e.Graphics.DrawString(numPag.ToString(), rodFont, Brushes.Black, e.MarginBounds.Right - (numPag.ToString().Length * rodFont.SizeInPoints), e.MarginBounds.Bottom + 5);
if (stringToPrint.Length > 0)
{
e.HasMorePages = true;
numPag++;
}
【问题讨论】:
-
为什么要重新发明已经存在并免费提供的东西?在您的应用程序中使用 Scintilla.NET 作为 textArea...scintillanet.codeplex.com
-
因为是上学的,必须自己动手。(可惜)
-
呃,等等,你是在寻求帮助自己做吗?使用 [homework] 标签。