0

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

2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by anuj6928
0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.