I wasn't doing anything in particular. I was just getting familiar with the firing sequence. Thanks for your answer.
>Robert,
>
>Part of the problem may be that you're probably not utilizing the Validating event correctly. The Validating event should be used to *stop* exiting the TextBox if it's not valid. So, after your MessageBox displays what is wrong with the entry, you should set e.Cancel = true, which will prevent exiting the TextBox until a valid entry is entered. In this case, you shouldn't want the button click to fire anyway.
>
>Now, if you've really meant to put it in the Validated event instead of the Validating event, then as long as you don't have a MessageBox in your Validated event, the events should fire in the correct sequence, as expected.
>
>What exactly is it that you're trying to do? Maybe we can suggest some alternatives ...
>
>~~Bonnie
>
>
>>I have noticed strange behaviors with VB.NET.
>>1. In the Validating method of a textbox place a messagebox command.
>>2. If the next object you select is a button the validation method of the textbox fires but the click method of the button does not.
>>
>>Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
>> MessageBox.Show("Validating")
>>End Sub
>>
>>Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
>> MessageBox.Show("hello")
>>End Sub
>>
>>Also
>>You have textbox1 with a validating method as above. causesvalidation = true
>>You have button1 with causesvalidation=false
>>You have button2 with causesvalidation=true
>>
>>1. You click into the textbox then into button1 (textbox.validating does not fire) then click into button2 and textbox.validating fires. I did not expect this.
>>
>>Hope this makes sense. I searched the archives but did not see a similiar problem.
>>
>>TIA
>>Robert
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only