locked
auto complete dropdown/textbox (asp .net/vb) RRS feed

  • Question

  • Hey guys ,

    Can you please give me the code for an auto complete drop down list or a textbox. i need to show the project names in it (which is in my database). i need to get the id of the corresponding project also, so i think an auto filling drop down will be better so that i can get the name as well as the id (as value).

    Hope u guys will help me out as usual....

    Friday, February 19, 2010 9:02 AM

Answers

  • Hey guys ,

    Can you please give me the code for an auto complete drop down list or a textbox. i need to show the project names in it (which is in my database). i need to get the id of the corresponding project also, so i think an auto filling drop down will be better so that i can get the name as well as the id (as value).

    Hope u guys will help me out as usual....


    Here is how to set up a ComboBox for AutoComplete.  In a new test project, add a ComboBox to Form1 and replace all the code with the following:

    Public Class Form1
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            ComboBox1.Items.Add("One")
            ComboBox1.Items.Add("Two")
            ComboBox1.Items.Add("Three")
            ComboBox1.Items.Add("One hundred")
        End Sub
    End Class
    
    

    Now select the ComboBox and set the AutoCompleteMode property to SuggestAppend .  Set the AutoCompleteSource property to ListItems .  Run the test project.  When you type the letter "o" you will see 2 selections displayed in the ComboBox drop-down section.  To use this example as you have asked about, just load the ComboBox with the data from your database

    :)


    Doug

    SEARCH ... then ask
    • Proposed as answer by Ji.Zhou Thursday, February 25, 2010 3:48 AM
    • Marked as answer by Martin_Xie Friday, February 26, 2010 5:28 AM
    Friday, February 19, 2010 11:41 AM

All replies

  • Hey guys ,

    Can you please give me the code for an auto complete drop down list or a textbox. i need to show the project names in it (which is in my database). i need to get the id of the corresponding project also, so i think an auto filling drop down will be better so that i can get the name as well as the id (as value).

    Hope u guys will help me out as usual....


    Here is how to set up a ComboBox for AutoComplete.  In a new test project, add a ComboBox to Form1 and replace all the code with the following:

    Public Class Form1
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            ComboBox1.Items.Add("One")
            ComboBox1.Items.Add("Two")
            ComboBox1.Items.Add("Three")
            ComboBox1.Items.Add("One hundred")
        End Sub
    End Class
    
    

    Now select the ComboBox and set the AutoCompleteMode property to SuggestAppend .  Set the AutoCompleteSource property to ListItems .  Run the test project.  When you type the letter "o" you will see 2 selections displayed in the ComboBox drop-down section.  To use this example as you have asked about, just load the ComboBox with the data from your database

    :)


    Doug

    SEARCH ... then ask
    • Proposed as answer by Ji.Zhou Thursday, February 25, 2010 3:48 AM
    • Marked as answer by Martin_Xie Friday, February 26, 2010 5:28 AM
    Friday, February 19, 2010 11:41 AM
  • Hello Shifad,

    For ASP.NET issues, please post in the ASP.NET Forum, :-)
    http://forums.asp.net/


    Best reagards,
    Ji Zhou - MSFT
    MSDN Subscriber Support in Forum
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Thursday, February 25, 2010 3:48 AM
  • Thanks!
    Friday, January 21, 2011 2:35 PM
  • I have just found this thread as I want the Comboboxes in my projects to replicate the behaviour of combos in the lamented MS Money and as described by Doug on 19 February 2010.

    However, when I type in the first letter, a supplementary list is presented.  If I choose any one in the second list, only the first is selected.  What do I need to do to select the item in the seconlist that I chose?

    regards

    Colin Reid

    Wednesday, June 27, 2012 3:15 PM