[問題] 列印不同字型與顏色的問題
我初學CSharp, 最近在練習寫一個記事本的程式,
遇到設置列印功能上的一個問題,
From MSDN
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);
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++;
}
//
//以下略
//
}
其中printFont被指定成Arial, 10,
而使用Graphics.DrawString又只能把顏色設成單一色,
我試圖用this.richTextBox.SelectionFont,
與this.richTextBox.SelectionColor去處理,
compiler可以過, 印也能印,
不過當我richTextBox中的文字, 同時使用不同的字型與顏色,
印出來整頁全部只會使用游標所在的字型與顏色,
已經找了一整天了還是找不到對於這兩個控制項的任何答案,
不知道是否有人能給我一個方向?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.69.103.245