views:

105

answers:

2

Hello,

I have a problem, I must to create a way to search the contents of a selected text file wich is displayed in multiple textbox (lblResult.Text). Use a simple search algorithm: Search for the entire search term entered by the user. For example, if the user enters "hello", search only for "hello". If the user enters "hello world", search only for the complete term "hello world", and not the individual "hello" or "world" words/terms. (This makes it easier.) Make your search case-insensitive.

Thanks a lot !!!!

And if it possible to create something event, for example to make bold searched text and go to this line , or something similar!

+4  A: 

Strings in .Net have an IndexOf(...) method that returns the location of a particular string within the string. Use the overload that takes a string (the text you're searching for, e.g. "hello" or "hello world") and a StringComparison parameter (use StringComparison.CurrentCultureIgnoreCase).

To highlight the searched-for text in your multiple-line TextBox (if it's found), set the TextBox's SelectionStart property (to the value returned from IndexOf(...)) and its SelectionLength property (to the length of the searched-for string).

MusiGenesis
A: 

Looks like you want us to do the job for you...

Nevertheless you should consider using regular expressions for string comparisons if your search gets too messy, just a word of advice. It also seems that you are trying to make a text editor. Don't!

Use something that some one else have already done, just search the interwebs.

Finally for the event look at this

Diones
Doing other peoples work for 'em is the whole concept of this site, Diones. I think you've missed the point, mate :)
roosteronacid
I almost feel regretful for answering trivial questions like these for these kind of reactions.
Diones