Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
as i type to google Text Box some of the relvent phrase appear in the textbox as a drop down. How does it form and work. i want that feature into my search window Form Application.
Is this possible
Posted
Comments
ridoy 29-Sep-13 14:39pm    
that is called auto-completeness as like the sample of ProgramFOX.

Try this:
C#
public Form1()
{
    InitializeComponent();
    yourTextBox.AutoCompleteMode = AutoCompleteMode.Suggest;
    yourTextBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
    AutoCompleteStringCollection source = new AutoCompleteStringCollection();
    source.AddRange(new string[]
                    {
                        "Item1",
                        "Item2",
                        "Item3"
                        // add more items if you want
                     });
    yourTextBox.AutoCompleteCustomSource = source;
}

Hope this helps.
 
Share this answer
 
Comments
Muhamad Faizan Khan 29-Sep-13 13:39pm    
quite good but "item1" i need to add manually which is really time consuming if i have 30 thousand records
Thomas Daniels 29-Sep-13 13:43pm    
You don't have to add them manually. You can read the records from a file, or from a database. The only thing you need is a string array that you can add to the source variable.
Muhamad Faizan Khan 30-Sep-13 3:38am    
can you give me demo?? with datbase
Thomas Daniels 30-Sep-13 10:38am    
Not exactly, because I don't know your database settings such as:
1. Connection String
2. Type of database
3. Column names

Reading from database is not very hard, I suggest you to go through the following links:
Using ADO.NET for beginners[^]
Connecting Windows Form Application With ADO.NET in C#[^]
http://msdn.microsoft.com/en-us/library/dw70f090.aspx[^]
http://csharp-station.com/Tutorial/AdoDotNet[^]
Muhamad Faizan Khan 30-Sep-13 12:05pm    
i familar with ado.net but don't know what to write instead of item.... ?? query??? or what???
 
Share this answer
 

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