How do i search all the lines in a richtextbox for a specific string in the line and then return the line number the string correspondents in.

[edit]using Visual c++ windows form CLR

What is this? c++ dotnet?

Visual c++ windows form clr

A richtextbox has a member Lines which is an array of all the lines of text (so Lines[0] would be the first line, etc). So yourRichTextbox->Lines->Length gives you the total number of lines. So you can do something like

for (int i = 0;i<richTextBox1->Lines->Length;i++)
{     
   if(richTextBox1->Lines[i]->Contains("findme"))
	 MessageBox::Show("Found it at line "+(i+1).ToString());
}

Of course that will only find the first instance of it, so if you want something else you'll have to keep track of where it was found, etc.