Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setfocus based on Tab Order = 1?
Message
From
10/11/1997 23:27:09
 
 
To
10/11/1997 21:07:04
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00059420
Message ID:
00059463
Views:
38
>>>Is it possible to detect which control has a tab order of "1" and to set focus to that control?
>>
>>lnMin = 9999
>>
>>FOR lnI = 1 TO _Screen.ActiveForm.ControlCount
>> IF _Screen.ActiveControl.TabIndex < lnMin
>> lnMin = _Screen.ActiveControl.TabIndex
>> loControl = _Screen.ActiveControl
>> ENDIF
>>ENDFOR
>>
>>loControl.SetFocus()
>
>How do you set the focus to a Label object? What if the object is disabled?
>
>Besides, you should use ActiveForm.Controls[lnI] instead of ActiveControl.
>
>Vlad

Thanks to all of you for responding so quickly. I posted this message at work and by the time I got home... wow!

Anyway, here's what I finally came up with:

* set focus to first field
IF THISFORM.DEMode <> "VIEW" && ADD or EDIT
nCtlNo = 1
DO WHILE nCtlNo < 99
IF THIS.CONTROLS(nCtlNo).TABINDEX = 1
THIS.CONTROLS(nCtlNo).SETFOCUS
nCtlNo = 99 && jump out of loop
ELSE
nCtlNo = nCtlNo + 1
ENDIF
ENDDO
ENDIF

Note that:
- All edit controls (textbox, combo box, checkbox, etc) are disabled in
VIEW mode and VIEW is the startup mode.
- I set the Tab Order to 1 for the 'first' field.
- this approach does not continue to test further once it finds the
'first' field.
- my standard form has a two-page pageframe with page one for 'Data Entry'
and page two for 'List'
- this code is in the Refresh method of Page1
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform