'RichTextBox exclude textbox input
I color some terms and codes entered in the richtexbox, but if the data comes from the text box, how can i disable the this coloring function for data came from textbox. Here is my code:
private void CheckKeyword(string word, Color color, int startIndex)
{
if (this.richTextBox1.Text.Contains(word))
{
int index = -1;
int selectStart = this.richTextBox1.SelectionStart;
while ((index = this.richTextBox1.Text.IndexOf(word, (index + 1))) != -1 )
{
this.richTextBox1.Select((index + startIndex), word.Length);
this.richTextBox1.SelectionColor = color;
this.richTextBox1.Select(selectStart, 0);
this.richTextBox1.SelectionColor = Color.Black;
}
}
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
this.CheckKeyword("#example", Color.FromArgb(141,0,78), 0);
}
so if textbox's text include the "#example" string i dont want to change color.
Also, Second way: if the incoming string is printed in quotes, how can I uncolor it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
