开发者

search textbox problem - fails when two of the same words are present

I'm trying to highlight all instances of words in a rich text box. I have been using the find method, but that finds the first instance.

I would like to start the first search at startPos = 0, then when I find an instance, start the new search from the last char of the found instance i.e.

newStartPos = (rtb.Text.IndexOf(text, type) + rtb.Text.Length);

any ideas...

Basically I need to find all instances of words in a list container as the user types into a richtextbox, for every 开发者_开发知识库hit I change the word colour within RTB and then do some maths on the chars within the complete RTB depending on the number of hits


Use the overload string.IndexOf(string, int), as startIndex you use lastFoundIndex + 1

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜