[RESOLVED] Usercontrols and Tabindex's...
I have this usercontrol that highlights itself when focus is set on it. The only problem is when it is the 0'th tabindex on a form... It doesn't highlight... It's heavily subclassed, and it does everything in its power to make sure it highlights when a user hovers it, or clicks on it. The highlight is executed upon focus, or mouseover. It is removed on mouseleave, and lostfocus. That all works fine.
If the tabindex IS 0, the focus wont be brought on until the user types something, or mouseovers it. I'd like some sort of way to know what the tabindex is :S
Re: Usercontrols and Tabindex's...
This seems to work:
Code:
Private Sub UserControl_Resize()
Debug.Print UserControl.Extender.TabIndex
End Sub
Re: Usercontrols and Tabindex's...
I would suggest avoiding using the Extender object unless this control will only be used in VB environments. Other environments may not support/supply a tabindex property.
P.S. If your control can get focus, is not hidden or disabled and is tab index zero, then it should be the control to get focus when the form first loads and is displayed. Additionally, you should get events firing too. For example, this uc (tabindex=0) fired these events when the project was run:
Code:
Initialize
ReadProperties
Resize: 1950, 1230
EnterFocus
GotFocus
Paint
Note: If your uc has controls inside of it that get focus (i.e., textboxes, etc), then the GotFocus event may not fire, but the EnterFocus should. Maybe you need to concentrate on EnterFocus/ExitFocus vs GotFocus/LostFocus ?
Re: Usercontrols and Tabindex's...
I took the things that you've both said into consideration. I used an if statement in the Paint event, to check if UserControl.Extender.TabIndex = 0, and if so, and if it's not in the IDE, then highlight. :D
Thanks guys.