I have searched the site but could not find a answer.
I have a listbox called "CompetitorDetailsOutput" I then have a textbox above called "searchbox" and a button called "searchbutton" The data in the list box constanly changes and get it data from a .txt file wich stores the data in the following format
string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12}", Name, CPSA, PostCode, Rank, Score1, Score2, Score3, Score4, Score5, Score6, Score7, Score8, TotalSingleScore);
the listbox then displays as follows
string.Format("{0,-20}|{1,-10}|{2,-9}|{3,-7}|{4,2}|{5,2}|{6,2}|{7,2}|{8,2}|{9,2}|{10,2}|{11,2}|{12,3}", Name, CPSA, PostCode, Rank, Score1, Score2, Score3, Score4, Score5, Score6, Score7, Score8, TotalSingleScore)
I want to be able to search the listbox as follows: user only enters data into "searchbox" and presses "searchbutton", system then searches the listbox, If it finds it selects the item in the listbox, if not then a close match is selected, if there are no close matches then a error message is displayed.
Code is C# and software VS 2008 Pro
Thanks
1./ Create an object with the properties that you want to search on
2./ Add your items as an object rather than as a string
3./ override the ToString() with the format that you want to display in the listbox
4./ Use Linq to query your objects as you like.
http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.findstring(v=vs.71).aspx
Try something like this to get your 'match' algorithm started: