Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2007

Tip: Looking for answers? Try searching our database.

string.IndexOf help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian Cook - 22 Aug 2007 01:30 GMT
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
rammer - 22 Aug 2007 07:30 GMT
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
Manish Bafna - 22 Aug 2007 08:56 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.