Hi,
There are few things wrong here.
There is an unused variable,
ArrayList arrInput = new ArrayList();
I am not sure why you have this variable for.
The string has been split into words and then foreach word a looking for the word "football" and getting the index of that word
int selectionStart = s.ToLower().IndexOf("football");
This will always return selectionSrart as 0; because you not looking for an index in the whole sentance instead just that word.
So in your code above, only the first 8 characters will be in the colour you set, but what you actual text you wanted wouldn't be in colour.
What you need is:
int index = 0;
while (index != -1)
{
index = str.IndexOf(rtbInput.Text, (index != 0) ? (index + 1) : index );
if ( index != -1)
{
rtbInput.SelectionStart = index;
rtbInput.SelectionLength = ("football").Length;
rtbInput.SelectionColor = Color.Red;
}
}
I hope this helps.
Regards
Jegan