i m using combo box in vb.net 2008 bt i m using the property as i can type in combobox this is done ... bt on running it ..when i m entering the wrong word in combo it will save the data .or sometimes gives error nd i want that it must stop writting or restrict the user to only rite that word that r already in the combo box list ....bt after this i have to handle tab nand enter

Recommended Answers

All 2 Replies

Let see your code, how you have done all that.

THAT IS THE FUNCTION....

Public Function ValidatecboKey(ByVal KeyChar As String, ByVal cbo As ComboBox) As Boolean

        KeyChar = Mid(cbo.Text, 1, cbo.Text.Length - cbo.SelectionLength) + KeyChar

        Dim Index As Integer = cbo.FindString(KeyChar)

        If Index < 0 Then
            Return True
        End If

        Return False

ND USING IT LIKE

Private Sub cboBankID_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cboBankID.KeyPress
        If Asc(e.KeyChar) = 8 OrElse Asc(e.KeyChar) = 27 Then
            e.Handled = False
        Else
            e.Handled = Admin.ValidatecboKey(e.KeyChar.ToString, cboBankID)
        End If
    End Sub
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.