Reputation: 9661
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!
Upvotes: 1
Views: 485
Reputation: 1481
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
Upvotes: -1
Reputation: 75296
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).
Upvotes: 5