I am working on validating a combo box. This does have a list of possible values but also allows for editing. So for example if the user does not select one of the available cities in the list they can type it in.

I have tried using the validation event but I seem to not begetting it.

ie...


Private Sub txtAddress1_Validating(ByVal sender As Object, ByVal _
e As System.ComponentModel.CancelEventArgs) Handles _
txtAddress1.Validating
'Check to see if the first name textbox is empty

If CType(sender, TextBox).Text = "" Then
MessageBox.Show("The first line of the address is required.", "Required Information", MessageBoxButtons.OK, MessageBoxIcon.Warning)
e.Cancel = True
End If

End Sub

Question:
Is txtAddress1 a ComboBox or TextBox?

It is a combo box. I must have grabbed the wrong section of code. I got it later last night. Thanks for asking.

I am working on validating a combo box. This does have a list of possible values but also allows for editing. So for example if the user does not select one of the available cities in the list they can type it in.

I have tried using the validation event but I seem to not begetting it.

ie...


Private Sub txtAddress1_Validating(ByVal sender As Object, ByVal _
e As System.ComponentModel.CancelEventArgs) Handles _
txtAddress1.Validating
'Check to see if the first name textbox is empty

If CType(sender, TextBox).Text = "" Then
MessageBox.Show("The first line of the address is required.", "Required Information", MessageBoxButtons.OK, MessageBoxIcon.Warning)
e.Cancel = True
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.