Tabindex and SetFocus
2006-05May-12
TabIndex defines in which order VFP cycles through the container. It doesn't, however, define which control receives the focus if you set the focus to the parent object. If you call the SetFocus() method of a container, VFP sets the focus to the element that has been instantiated first. That is, VFP scans the Objects collection in pyhsical order and sets the focus to the first element that can receive the focus. VFP does NOT set the focus to the control with the lowest TabIndex. The following program demonstrates this.
Public goForm
goForm = CreateObject("MyForm")
goForm.Show()
goForm.myContainer.SetFocus()
Define Class MyForm as Form
Add object Text1 as Textbox with Top = 0
Add Object myContainer as MyContainer with Top = 30
Add object Text2 as Textbox with Top = 130
EndDefine
Define Class myContainer as Container
Add Object Text1 as Textbox with Top=0, TabIndex = 2
Add Object Text2 as Textbox with Top=25, TabIndex = 1
Add Object Text3 as Textbox with Top=50, TabIndex = 3
EndDefine