Home All Groups Group Topic Archive Search About
Author
12 Apr 2006 8:03 AM
Helen Trim
Is there any way of getting a combo box to move to an item as the user types?
  For example, if they type FR in a country list, it scrolls down to France. 
This is the usual way that a combo box works, but it doesn't seem to happen
in VB .NET.  Do I have to add code to get it to do this or is there a
property setting that allows this?

TIA
--
Helen

Author
12 Apr 2006 8:46 AM
Ken Tucker [MVP]
Hi,

        In vb 2005 the combobox has some autocomplete functions to help with
that.

        Dim strConn As String
        Dim da As SqlDataAdapter
        Dim conn As SqlConnection
        Dim ds As New DataSet

        strConn = "Server = .;Database = NorthWind; Integrated Security =
SSPI;"
        conn = New SqlConnection(strConn)

        da = New SqlDataAdapter("Select * from Products", conn)

        da.Fill(ds, "Products")

        Dim ac As New AutoCompleteStringCollection
        For Each dr As DataRow In ds.Tables("Products").Rows
            ac.Add(dr.Item("ProductName").ToString)
            ComboBox1.Items.Add(dr.Item("ProductName").ToString)
        Next


        ComboBox1.AutoCompleteMode = AutoCompleteMode.Append
        ComboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
        ComboBox1.AutoCompleteCustomSource = ac


For vb.net and vb.net 2003 try using the intellicombo
http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=30138E02-C2C3-41CD-BC6A-09BC8FD2860B

Ken
----------------

Show quoteHide quote
"Helen Trim" <HelenT***@discussions.microsoft.com> wrote in message
news:16CB8CFA-DB04-47B2-BF7C-BB3C64066E78@microsoft.com...
> Is there any way of getting a combo box to move to an item as the user
> types?
>  For example, if they type FR in a country list, it scrolls down to
> France.
> This is the usual way that a combo box works, but it doesn't seem to
> happen
> in VB .NET.  Do I have to add code to get it to do this or is there a
> property setting that allows this?
>
> TIA
> --
> Helen