Hello everyone,
I'm having trouble making a search box for my program.
This is a not a school project or anything, just a personal project I've been working on. Therefore, any possible solutions are welcomed.
This is basically a program is a dictionary program of sorts. The user enters in a word and a definition. The word is then stored in a collection (WordCollection), and this collection is the datasource for a listbox control which the user scrolls through to find words/definitions.
The problem I have is not with the program, but the import/export and search functionality within the program.
Right now, I am using .csv format to import/export the file. The exported lines would look something like this:
the garbage people throw out, garbage is waste
The problem is when I have two definitions like this:
i'm a pig, you're not a pig // fails search
i am a pig, you're not a pig // fails search
immediate, right now // works, so I assume there is a problem with space/apostrophe in my search mechanism right now
Here's the code I'm using at the moment.
// sort in alphabetical order
words.Sort(delegate(Word x, Word y) { return String.Compare(x.WordInput, y.WordInput); });
foreach (Word word in words)
{
if (word.WordInput == txtSearch.Text)
{
int index = words.IndexOf(word);
lstWordList.SetSelected(index, true);
break; // select the first match
}
}
Any help or solution would be appreciated.