when insert in the first char then it display the related item the combo box

Recommended Answers

All 9 Replies

Please Re-read your line posted by you then reply if you understand any thing after reading the line.
Please post your problem clearly with your work (code) what every you try till now

See if this helps.
1 ComboBox

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '//--- For testing purposes.
        Dim arTemp() As String = {"ComboBox1", "AutoCompleteSource", "AddRange", "Items", "With", "End With"}
        ComboBox1.Items.AddRange(arTemp) '---\\
        '//These options can be located in the ComboBox's Properties.
        ComboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
        ComboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend '// also "Append", "None", and "Suggest".
        '// use this to load/reload the AutoCompleteList with the ComboBox items.
    End Sub

    Private Sub loadMyCoolAutoCompleteList(ByVal selectedComboBox As ComboBox)
        selectedComboBox.AutoCompleteCustomSource.Clear() '// Clear AutoCompleteList.
        For Each itm As String In selectedComboBox.Items '// loop thru all items in the ComboBox.
            selectedComboBox.AutoCompleteCustomSource.Add(itm) '// add item to your AutoCompleteList.
    End Sub
End Class

Hi all! I have a problem with autocompletion of a combobox..the combobox includes the names of employees.When I insert the first character the list whith the names which start by this letter doesn t appear any more.. :(
I don t know what happening.. i think that i changed something by mistake because when i had wrote it it was ok.. Please help! this is my code now:

' Declare SqlDataAdapter object.
Dim CrewDA As New SqlDataAdapter()
' Dim StreetNameDA As New SqlDataAdapter()

' Assign a new SqlCommand to the SelectCommand property
CrewDA.SelectCommand = New SqlCommand()

'Set the SelectCommand properties..
CrewDA.SelectCommand.Connection = conn
CrewDA.SelectCommand.CommandText = "SELECT Crew, ID FROM T_CREWS "

'Create the DataSet
Dim DS As New AMRtoSQLDataSet

'Fill the dataset with data
CrewDA.Fill(DS, "CrewTable")

'Fill the Crew name at combo box
cboCrew.DataSource = DS.Tables("CrewTable")
cboCrew.DisplayMember = "Crew"
cboCrew.ValueMember = "ID"
Me.cboCrew.SelectedValue = -1

'*********************AUTOCOMPLETION Combo box USER*************************************
Dim col As New AutoCompleteStringCollection ' From which our names will come

Dim i As Integer
For i = 0 To DS.Tables(0).Rows.Count - 1

'this is the main part
cboCrew.AutoCompleteSource = AutoCompleteSource.CustomSource
cboCrew.AutoCompleteCustomSource = col
cboCrew.AutoCompleteMode = AutoCompleteMode.Suggest

Change the auto complete mode for your combobox so it suggest and append

cboCrew.AutoCompleteMode = AutoCompleteMode.SuggestAppend

Thanks for your reply but it didn' t work.. :(

I might be your custom source.
If you have your list populated before you can try getting the values from the listitem.

Private Sub Sample()
        cboCrew.AutoCompleteMode = AutoCompleteMode.SuggestAppend
        cboCrew.AutoCompleteSource = AutoCompleteSource.ListItems
    End Sub

>>I might be your custom source.
Can I be one also?:D

please inform me how to connect table with vb.net and i need a code

smerinas, you need to be more clear.
Explain little more, what you are trying to do and how you want to approach it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.