-1
假設有兩行。紅線。藍線。 誰可以幫忙。RichTextBox中的多個文本格式
假設有兩行。紅線。藍線。 誰可以幫忙。RichTextBox中的多個文本格式
你可以使用:
void AppendText(RichTextBox box, Color color, string text)
{
int start = box.TextLength;
box.AppendText(text);
int end = box.TextLength;
// Textbox may transform chars, so (end-start) != text.Length
box.Select(start, end - start + 1);
box.SelectionColor = color;
// could set box.SelectionBackColor, box.SelectionFont, etc...
box.SelectionLength = 0; // clear
}
然後
AppendText(rtb, Color.Red, "line1");
AppendText(rtb, Color.Blue, "line2");
我認爲你必須表現出一些更多的努力纔有人願意幫助你。你甚至沒有說明你的問題。 –
我同意@Felix,無論如何,我想幫助你,因爲你是新來的。記得在問這裏之前試着寫下你的代碼,展示你的努力並寫出一個清晰而詳細的問題。歡迎來到SO。 – Marco
我感到這種奇怪的感覺,這個問題背後有一些深刻的哲學含義。或者也許只是蘇斯博士。 – Amy