Public Function validateCombo(txt As ComboBox) As Boolean If Not txt.Items.Contains(txt.Text.ToString) Then Return False Else Return True End If End Function
Private Sub cboFund_Validating(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles cboFund.Validating If Not bnformclosing Then If cboFund.Text <> String.Empty Then If validateCombo(cboFund) Then e.Cancel = False Else MessageBox.Show("The item: " & cboFund.Text & " is not a valid fund", "Invalid fund", MessageBoxButtons.OK, MessageBoxIcon.Information) e.Cancel = True End If End If End If End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)