-
focus problem
I have a mess of controls on my form.
Using the arrow keys the focus passes from one command button to the next - fine. But then it disappears off the screen. Nothing has the focus.
How can I check if nothing has the focus then give focus to command1.
Cheers a lot
Phil
-
Re: focus problem
It doesn't happen that "nothing has the focus". Something has the focus, its only that it is not seen. For example, we do not see a picturebox having focus. Identify such elements and set their tabstop property to false. You can do it in one go during form load like
dim aControl as Control
for each aControl in Controls
if TypeOf aControl is PictureBox then aControl.Tabstop = false
next
To identify which control has the focus, put a timer on your form, set its interval to 2 seconds, say, and in the timer event, write
MsgBox ActiveControl.Name
Now play with your keys. When the focus seems to disappear, wait some time and the name of the control with the focus will pop up.
-
Re: focus problem
Something has the focus somewhere. Check the TabIndex property of the last control that gained and lost the focus. Then look for a control with a higher number. The control may be hidden behind another, Could be a menu item or a control that does not display the Focus rectangle.
John G
-
Re: focus problem
Hmm - thanks guys.
Yes, focus was being trapped by picture1. Once there, the arrow keys no longer switch focus though the tab key does.
I can do something about that - no problem - thanks very much.
Phil