|| Published on :
Thursday, July 24, 2014 || Views:
AutoComplete Feature Winform Application C Sharp Winform Handy Trick and Tips Winform Example
In this article, I will explain you how can we use the AutoComplete Feature in winform application using C Sharp. For example I have created a winform application using c sharp from the Visual Studio. You can follow the given below steps to achieve the solution. For any graphical user interface, this may become very usefull feature that makes it easy for users to fill in applications or forms by suggesting them suitable words or phrases in appropriate text boxes.
So, while it may look like a tough job; it’s actually quite easy to use this feature. The text boxes in C Sharp contain an AutoCompleteMode which can be set to one of the three available choices i.e. Suggest , Append or SuggestAppend. Any choice would do but my favorite is the SuggestAppend.
This can be done through design mode using properties window for textBox1 and textBox2 as displayed in below figure
We can change properties of these textboxes thorugh code behind like :
textBox2.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
textBox2.AutoCompleteSource = AutoCompleteSource.CustomSource;
Next we must set the AutoCompleteSource to CustomSource because we will supply the words or phrases to be suggested. The last step includes calling the AutoCompleteCustomSouce.Add() function with the required.
Full Code Behind Source Code
1 using System;
2 using System.Windows.Forms;
4 namespace AutoComplete_feature
6 public partial class Form1 : Form
8 public Form1()
13 private void Form1_Load(object sender, EventArgs e)
16 textBox2.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
17 textBox2.AutoCompleteSource = AutoCompleteSource.CustomSource;
22 private void button1_Click(object sender, EventArgs e)
Output in Running Mode
Hope you have enjoyed this step by step tutorial to learn how to AutoComplete Feature in winform application using C Sharp.
Download Source Codes