Why when i click OK its coloring all the text in the richTextBox in Red?
<p>I have a click button event when im adding and removing text from the richTextBox2.
Each time im clicking on OK all the text is colored in Red thisi s the function im using in the button click event:</p>

<pre><code>private void tryingRichTextBox()
        {
            using (var w = new StreamWriter(keywords))
            {
                crawlLocaly1 = new CrawlLocaly();
                crawlLocaly1.StartPosition = FormStartPosition.CenterParent;
                DialogResult dr = crawlLocaly1.ShowDialog(this);
                if (dr == DialogResult.OK)
                {
                    if (LocalyKeyWords.ContainsKey(mainUrl))
                    {


                        clearRichtextBox();

                            LocalyKeyWords[mainUrl].Clear();
                            LocalyKeyWords[mainUrl].Add(crawlLocaly1.getText());
                    }
                    else
                    {
                        clearRichtextBox();
                        LocalyKeyWords[mainUrl] = new List&lt;string&gt;();
                        LocalyKeyWords[mainUrl].Add(crawlLocaly1.getText());
                    }
                    Write(w);
                    clearRichtextBox();                        
                }
                if (dr == DialogResult.Cancel)
                {
                    Write(w);
                }
            }
        }
</code></pre>

<p>This function i load in the constructor:</p>

<pre><code>private void richTextBoxLoadKeys(Dictionary&lt;string, List&lt;string&gt;&gt; dictionary, string FileName)
        {
            string line = System.String.Empty;
            using (StreamReader sr = new StreamReader(keywords))
            {
                while ((line = sr.ReadLine()) != null)
                {
                    tokens = line.Split(',');
                    dictionary.Add(tokens[0], tokens.Skip(1).ToList());
                    richTextBox2.AppendText("Url: " + tokens[0] + " --- " + "Localy KeyWord: " + tokens[1]+Environment.NewLine);
                    AppendText(tokens[1], Color.Green);
                    AppendText("Url: ", Color.Red);
                }
                sr.Close();
            }
        }
</code></pre>

<p>This function clear the richTextBox:</p>

<pre><code>private void clearRichtextBox()
        {
            StringBuilder sb = new StringBuilder();
            foreach (KeyValuePair&lt;string, List&lt;string&gt;&gt; kvp in LocalyKeyWords)
            {
                for (int i = 0; i &lt; kvp.Value.Count(); i++)
                {
                    sb.AppendFormat("Url: {0} --- Localy KeyWord: {1}{2}", kvp.Key, kvp.Value[i], Environment.NewLine);
                }
            }
            string viewString = sb.ToString();
            if (viewString != richTextBox2.Text)
            {
                richTextBox2.Text = viewString;
            } 
</code></pre>

<p>And this is the function im using to Color the specific text in the richTextBox2. 
Im using this function only in the richTextBoxLoadKeys function where im loading in the constructor.</p>

<pre><code>void AppendText(string text,Color color)
        {

            int len = this.richTextBox2.TextLength;
            int index = 0;
            int lastIndex = this.richTextBox2.Text.LastIndexOf(text);

            while (index &lt; lastIndex)
            {
                this.richTextBox2.Find(text, index, len, RichTextBoxFinds.None);
                this.richTextBox2.SelectionColor = color;
                index = this.richTextBox2.Text.IndexOf(text, index) + 1;
            }
        }
</code></pre>

<p>I cant figure out why when im clicking OK in the button click event its coloring all the text in the richTextBox in Red ?</p>
