Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
VC++ string manuplation help?
ok SoStringsAreDriving (Me, Nuts);
1)How to get the location of the caret (The flashing |, I don't whether that's the caret or not.) in a richTextBox?
2)How to... let's say I want to color all the instances of the word "green" in the richTextBox green, how to do that? What I do is that I use the indexOf function. After 20 builds or so, it finally works, but only for the first "green". The other greens are still black.
Thank you.
1 Answer
- 1 decade agoFavorite Answer
try this code this will give you all the occurrences of word green
private void button1_Click(object sender, EventArgs e)
{
int index=0;
while(index>=0)
{
if (index != 0)
index = index + 5; //+5 for word green
index = richTextBox1.Text.IndexOf("green", index);
MessageBox.Show(index.ToString()); //i just placed it in message box
// you do you work with the index of word green
if (index == -1)
break;
}
}