By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,574 Members | 1,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,574 IT Pros & Developers. It's quick & easy.

string.IndexOf help

P: n/a
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
Aug 22 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

On Aug 22, 3:30 am, Brian Cook <brian.c...@bnsf.comwrote:
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

Aug 22 '07 #2

P: n/a
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.Fin d("one",previndex,RichTextBoxFinds.WholeWord ));
if (previndex ==0 )
{
previndex++;
}
richTextBox2.AppendText(richTextBox1.Lines[richtextboxlineno]);
}
}
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Brian Cook" wrote:
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
Aug 22 '07 #3

P: n/a
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.

"rammer" wrote:
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

On Aug 22, 3:30 am, Brian Cook <brian.c...@bnsf.comwrote:
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


Aug 22 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.