i have a combobox that have items form database. the problem is when i selected an item from that combobox it disappeared but still in the choices. i want the combobox.selecteditem should be appearing if i selected it.

here's my code :

Dim strsql = "select * from DesignationEveryDept where Department = '" & DeptNameCB.Text & "'"
        Dim acscmd As New OleDb.OleDbCommand
        acscmd.CommandText = strsql
        acscmd.Connection = asconn
        acsdr = acscmd.ExecuteReader()
        DesEmpCB.Items.Clear()
        While (acsdr.Read())
            DesEmpCB.Items.Add(acsdr("Designation"))
        End While
        acscmd.Dispose()
        acsdr.Close()

kindly help me. thank you in advance~

Recommended Answers

All 2 Replies

What you mean about disappeared? you mean remove selected item from combobox?

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    ComboBox1.Items.Remove(ComboBox1.SelectedItem)
End Sub

no. what is happening now is when i selected item, it is refreshed and not selected. :(

Be a part of the DaniWeb community

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