Dim frm as New Form1 frm.MdiParent = Me frm.Show()Now on Form1, you are handling the TextBox1's validating event and are cancelling the event (probably based on some condition):
Private Sub TextBox1_Validating(ByVal sender As Object, _ ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating 'If some condition blah blah blah e.Cancel = True End SubWhen you run your application, open Form1 and trigger the event, the focus remains in the TextBox1 as expected... until.....
Now you want to open Form2 while Form1 is still open (a perfectly valid use case for an MDI application). BUT, once Form2 opens, even though the form is activated, no control can receive focus on Form2. It basically renders Form2 useless and in a user's eyes it looks like the form is not responding. WHAT!? Why in the world is the Textbox1's Validating event being raised at all on Form1 once Form2 is active? This has got to be a bug or it is just plain retarded. I fail to see why you would ever want this behavior. This is not a problem if the application is not an MDI application. In that case the event will not be raised if the form is not active.
I can't figure out how to prevent the Validating event from being raised, however, I did find a work-around. You can use this check in the handler to avoid running your handler code:
Private Sub TextBox1_Validating(ByVal sender As Object, _ ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating If Me.MdiParent.ActiveMdiChild Is Me Then 'If some condition blah blah blah e.Cancel = True End If End SubThis is moderately painful because I have to search my app for "_Validating" and add this line to all the handlers. If anyone's got a better idea I'm all ears.