Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Working with Combo box Auto Complete Property in C# and VB using .NET 2.0

Author: Zunnair
Download Source Code : 730_ComboAutoComplete.zip

In this simple article you will learn that how to work with Combo box Auto Complete Property.

Simply just create New Project of windows application in C#.

 

Drag 3 buttons, 1 Combo box and one label on the form.

 

Now write following code on form Load

 

C#

 

private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "DevAsp AutoComplete Combo";

            button1.Text = "Load";

            button2.Text = "Auto Complete ON";

            button3.Text = "Auto Complete OFF";

           

            comboBox1.Items.Clear();

            comboBox1.Items.Add("ABCDEF");

            comboBox1.Items.Add("ACDEF");

            comboBox1.Items.Add("ADEF");

            comboBox1.Items.Add("ADEF");

            comboBox1.Items.Add("AEF");

            comboBox1.Items.Add("AFSDF");

            comboBox1.Items.Add("BABCD");

            comboBox1.Items.Add("BBCD");

            comboBox1.Items.Add("BCDBA");

            comboBox1.Items.Add("CDBA");

            comboBox1.Items.Add("CBA");

 

        }

 

VB

 

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)

        Me.Text = "DevAsp AutoComplete Combo"

        button1.Text = "Load"

        button2.Text = "Auto Complete ON"

        button3.Text = "Auto Complete OFF"

 

        comboBox1.Items.Clear()

        comboBox1.Items.Add("ABCDEF")

        comboBox1.Items.Add("ACDEF")

        comboBox1.Items.Add("ADEF")

        comboBox1.Items.Add("ADEF")

        comboBox1.Items.Add("AEF")

        comboBox1.Items.Add("AFSDF")

        comboBox1.Items.Add("BABCD")

        comboBox1.Items.Add("BBCD")

        comboBox1.Items.Add("BCDBA")

        comboBox1.Items.Add("CDBA")

        comboBox1.Items.Add("CBA")

 

    End Sub

Now write following code on Button Click events

 

C#

 

private void button1_Click(object sender, EventArgs e)

        {

            comboBox1.Items.Clear();

            comboBox1.Items.Add("ZBCDEF");

            comboBox1.Items.Add("XCDEF");

            comboBox1.Items.Add("VDEF");

            comboBox1.Items.Add("BDEF");

            comboBox1.Items.Add("BEF");

            comboBox1.Items.Add("MFSDF");

            comboBox1.Items.Add("MTBCD");

            comboBox1.Items.Add("MTCD");

            comboBox1.Items.Add("MTYCA");

            comboBox1.Items.Add("JDBA");

            comboBox1.Items.Add("CBA");

        }

 

        private void button2_Click(object sender, EventArgs e)

        {

            comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;

           comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;

           comboBox1.Focus();

 

        }

 

        private void button3_Click(object sender, EventArgs e)

        {

            comboBox1.AutoCompleteMode = AutoCompleteMode.None;

            comboBox1.AutoCompleteSource = AutoCompleteSource.None;

            comboBox1.Focus();

        }

VB

 

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)

        comboBox1.Items.Clear()

        comboBox1.Items.Add("ZBCDEF")

        comboBox1.Items.Add("XCDEF")

        comboBox1.Items.Add("VDEF")

        comboBox1.Items.Add("BDEF")

        comboBox1.Items.Add("BEF")

        comboBox1.Items.Add("MFSDF")

        comboBox1.Items.Add("MTBCD")

        comboBox1.Items.Add("MTCD")

        comboBox1.Items.Add("MTYCA")

        comboBox1.Items.Add("JDBA")

        comboBox1.Items.Add("CBA")

    End Sub

 

    Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs)

        comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend

        comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems

        comboBox1.Focus()

 

    End Sub

 

    Private Sub button3_Click(ByVal sender As Object, ByVal e As EventArgs)

        comboBox1.AutoCompleteMode = AutoCompleteMode.None

        comboBox1.AutoCompleteSource = AutoCompleteSource.None

        comboBox1.Focus()

    End Sub

 

With these following properties

 

comboBox1.AutoCompleteMode = AutoCompleteMode.None

comboBox1.AutoCompleteSource = AutoCompleteSource.None

 

you can make combobox user friendly

 

Article Comments
Excellent work !

Posted on 8/13/2008 11:35:50 PM by Akshay joshi

Nice coding
Thanks
sezhi

Posted on 2/10/2010 6:28:52 AM by sezhi

good job

Posted on 4/22/2010 7:58:41 AM by taimoor

This is an excellent article, thank you very much for it,
I have found here much useful information in
http://ambienbuy.net/VALIUM.html

Posted on 5/22/2010 3:59:44 PM by http://ambienbuy.net

This is an excellent article, thank you very much for it

Posted on 5/23/2010 5:34:56 PM by http://ambienbuy.net

Excellent work........thanks buddy

Posted on 6/11/2010 7:05:58 AM by vipul

Very nice site!

Posted on 7/6/2010 2:08:30 AM by Very nice site!

Very nice site!

Posted on 7/28/2010 5:58:25 AM by Very nice site!

Very nice site!

Posted on 8/8/2010 3:47:36 AM by Very nice site!

Hello i have a problem with combobox because i tried to read only some item of combobox but this is not possible because items not have any properties please if any suggestion is available than contact me

Posted on 8/18/2010 7:49:57 AM by Vaishali Jain

Very nice site!

Posted on 9/27/2010 7:48:39 AM by Very nice site! is it yours too http://apeoixy.com

Very nice site!

Posted on 9/27/2010 7:48:40 AM by Very nice site!

Very nice site!

Posted on 10/30/2010 5:42:48 AM by Very nice site!

Hello! ceeccce interesting ceeccce site!

Posted on 11/14/2010 5:05:30 AM by Hello! ceeccce interesting ceeccce site!

Very nice site!

Posted on 11/20/2010 10:03:58 AM by Very nice site!

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Working with Status Strip Label control in C# and VB using .NET 2.0.

Disclaimer - Privacy
© 2002-2017 DevASP.net