Auto Fill or Intellisense in C#:
I know you are curious about intellisense in C# because now a days about all big application uses intellisense including Softwares like Visual Studio, SQL Server Web Sites like Facebook in their Search Bar or any other Search Engine uses in their Search Bar.
Today you will learn easily to make use of intellisense in your Windows Form applications. It is easy to use intellisense in a Combo Box and Auto Fills the Combo Box when User enter the Starting Keywords.
Steps to Add Auto Fill / Intellisense in C#:
- First of all, Add a Combo Box From the Tool Box in Windows Form Application as shown below, drag the Combo box to win Form Application to use this.
- Put some Values like names in the items of that Combo Box
- A Dialog will Open, Enter one name per line
- Write Following Code in this event:
{
int i;
string original;
string word_founded;
// eliminate the function keys
if ((e.KeyCode == Keys.Back) ||
(e.KeyCode == Keys.Left) ||
(e.KeyCode == Keys.Right) ||
(e.KeyCode == Keys.Up) ||
(e.KeyCode == Keys.Down) ||
(e.KeyCode == Keys.Delete) ||
(e.KeyCode == Keys.PageUp) ||
(e.KeyCode == Keys.PageDown) ||
(e.KeyCode == Keys.Home) ||
(e.KeyCode == Keys.End))
{
return;
}
original = this.comboBox1.Text; // Store the original text that user types
i = this.comboBox1.FindString(original); // Find the first match for the typed value.
if (i > -1)// first match.
{
word_founded = this.comboBox1.Items[i].ToString();
this.comboBox1.SelectedIndex = i; // Select this item.
this.comboBox1.SelectionStart = original.Length; // this code select the part of word that was added automatically and replaces it.
this.comboBox1.SelectionLength = word_founded.Length;
}
}
Output:
Make a Web Browser in C#
Thanks For Reading, Contact us if You have any Query
Commenting on a post is a great way to show some love for what you're seeing.