I have a sting that is actually an xml.
I am using a procedure that gives me the string in a formated way but i also want to have it colorized within the richtextbox. The procedure i am using now is
private void beautify() { // richTextBox1.HideSelection = false; richTextBox1.BackColor = Color.White; richTextBox1.SelectAll(); richTextBox1.SelectionColor = Color.IndianRed; int firstLine = richTextBox1.Text.IndexOf('\n', 1); HighlightText(richTextBox1, "<", Color.Blue,true); HighlightText(richTextBox1, ">", Color.Blue,true); HighlightText(richTextBox1, "=", Color.Blue,true); HighlightText(richTextBox1, "\"", Color.Blue,true); HighlightText(richTextBox1, "</", Color.Blue,true); HighlightText(richTextBox1, "=>", Color.Blue, true); string[] str = richTextBox1.Text.Split('\u0022'); for (int i = 0; i < str.Length; i++) { if(i%2 != 0) HighlightText(richTextBox1, str[i], Color.Black,false); } richTextBox1.Select(0, firstLine); richTextBox1.SelectionColor = Color.Blue; }
It mostly works with some bugs, but my bigest problem is that for very large xml it is taking way to long. I was wondering if there is a library or something to handle this faster.
Thank you for reading
No comments:
Post a Comment