private void LoadKeys(Dictionary<string,List<string>> dictionary, string FileName)
{
string line = System.String.Empty;
using (StreamReader sr = new StreamReader(keywords))
{
while ((line = sr.ReadLine()) != null)
{
string[] tokens = line.Split(',');
dictionary.Add(tokens[0], tokens.Skip(1).ToList());
richTextBox2.AppendText("Url: " + tokens[0] + " --- " + "Localy KeyWord: " + tokens[1]+Environment.NewLine);
ColorText(richTextBox2, Color.Red);
}
}
}
和功能 ColorText:
public void ColorText(RichTextBox box, Color color)
{
box.SelectionStart = box.TextLength; box.SelectionLength = 0;
box.SelectionColor = color;
box.SelectionColor = box.ForeColor;
}
但它没有用红色着色任何东西。没有改变。例如,我希望能够仅将令牌 [0] 和绿色令牌 [1] 着色为红色。
我该怎么做 ?