Strange GotFocus Event

HARRY

Active Member
Licensed User
Longtime User
Hi,

I modified an 'old' application by adding a TextBox on a form. Then I added a GotFocus, LostFocus and KeyPress event for this TextBox as I did previously for a number of other TextBoxes on the form. For each type of event the added events refer to the same Sub.

Before adding this new TextBox everything worked well. Now, after adding the new TextBox the Form.Show method rises a GotFocus event for the new TextBox.

Can anyone explain?

Harry
 

agraham

Expert
Licensed User
Longtime User
When a Form is Shown the last control added that can have the focus is given it, hence the GotFocus event. Strictly it is the first control in the Tab Order. Normally the Tab Order is the order in which controls are added but you can alter it in the Designer with Tools -> Bring To Front or Send To Back used in succession on the controls in the Tab Order you want.
 
Top