Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setfocus based on Tab Order = 1?
Message
From
10/11/1997 23:43:51
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00059420
Message ID:
00059464
Views:
33
>>>>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

1. What do you do if the 1st control with TabIndex = 1 is a label?
2. You can use the This.ControlCount instead of 99 (99 will give you an error if you try to access the Controls[99] and you don't have 99 controls (the same for any other value > ControlCount, obviously))
3. Are you sure you'll always have a TabIndex = 1?

Vlad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform