In my project I want to search thru a text in a text box or RichTextBox.
When I search I want to list all lines that contain the string I am
searching for.
e.g.
one plus four
two plus four
three plus four
one minus four
one divided by four
two minus four
two divided by four
three plus five
three minus five
search for the string "one", and display the contents of all lines in the
TextBox/RichTextBox.
I envision that the TextBox/RichTextBox would be a control that is hidden
normally and then the search form would resize and show the
TextBox/RichTextBox control with the results.
Could someone please post a sample?
Thanks,
Brian
Hello, Brian
so what exactly are you looking for? example of searching that
richtextbox or resizing form?
im sure nobody has the will to make programs for you but surely
someone may help if you have precise questions.
sorry for my english:P
> In my project I want to search thru a text in a text box or RichTextBox.
>
[quoted text clipped - 25 lines]
>
> Brian
Brian Cook - 22 Aug 2007 12:26 GMT
Hi Rammer, I am looking for a sample/snipit of how to utilize the IndexOf
method that makes better sense than the ones on the MSDN Library.
I am just not grasping that one.
> Hello, Brian
>
[quoted text clipped - 34 lines]
> >
> > Brian
Hi,
I think you are looking for something like below:
static int previndex;
private void button1_Click(object sender, System.EventArgs e)
{
for(int lineno = 0;lineno < richTextBox1.Lines.GetLength(0);lineno++)
{
previndex = richTextBox1.Find("one",previndex,RichTextBoxFinds.WholeWord
);
int richtextboxlineno =
richTextBox1.GetLineFromCharIndex(richTextBox1.Find("one",previndex,RichTextBoxFinds.WholeWord ));
if (previndex ==0 )
{
previndex++;
}
richTextBox2.AppendText(richTextBox1.Lines[richtextboxlineno]);
}
}

Signature
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.
> In my project I want to search thru a text in a text box or RichTextBox.
>
[quoted text clipped - 25 lines]
>
> Brian
Brian Cook - 22 Aug 2007 12:30 GMT
Manish that example I think will meet the needs and educates me further.
I will substitue the fixed string into a variable, so that I can search for
different stuff.
I appreciate the example.
Many Thanks,
> Hi,
> I think you are looking for something like below:
[quoted text clipped - 44 lines]
> >
> > Brian