Click here to Skip to main content
15,894,740 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How to make (TEXT BOX) auto complete sources from text file
Posted
Updated 7-Jan-15 7:02am
v2
Comments
CHill60 7-Jan-15 13:12pm    
What have you tried and where are you stuck?
Ali Omran 7-Jan-15 13:23pm    
I Want to make TextBox1.AutoCompleteCustomSource =
by using AutoCompleteSource is File system {from a text file}
Sergey Alexandrovich Kryukov 7-Jan-15 13:14pm    
TextBox? Which one? Full type name, please.
—SA
Ali Omran 7-Jan-15 13:21pm    
I Want to make TextBox1.AutoCompleteCustomSource =
{from a text file}
Sergey Alexandrovich Kryukov 7-Jan-15 13:27pm    
Type name please. Full type name. If you don't know what is type or what it full type name, you should not develop the UI but should start programming from the very beginning, to avoid total waste of time and frustration.
—SA

1 solution

Please see my comment to the question. As you did not even specify what TextBox type you use, we don't even know what we are talking about.

But listen to my speculations. No matter what it is, it looks like you already know how to enable auto-complete; your question is only about the text file. Therefore, you should be able to read a text file into required data source, not matter what it is. The best you can use is the class System.IO.StreamReader with using statement:
http://msdn.microsoft.com/en-us/library/system.io.streamreader%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/htd05whh.aspx[^].

Alternatively, you can use System.IO.File.ReadAllLines (I think I can quite safely assume that your file is not too big) in one shot:
http://msdn.microsoft.com/en-us/library/system.io.file.readalllines%28v=vs.110%29.aspx[^].

If your data source have to be just a bit more structured than that set of text lines, it is a fair reason to use XML (not, also a text file). Please see my recent answer: XML Help please - Downloaded a file and I have no clue how to read it[^].

What it the data source, how to populate its data — it's all on you, because you did not specify what you are using. If you still have further questions, please specify it and ask them.

—SA
 
Share this answer
 
Comments
Abhinav S 7-Jan-15 13:35pm    
5
Sergey Alexandrovich Kryukov 7-Jan-15 14:08pm    
Thank you, Abhinav.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900