General information
Category:
Forms & Form designer
>Using VFP6 - I have a pageframe with multiple pages and each time the user changes the page I want the cursor to go to the first object on the new page. Is there any easy way of finding the first object on the page without hardcoding it?
>
>Thanks-
I read Rich and Nancy's replies but you can easily write a method to accomodate what you want. I've one called .SetFocusThisIndex(oTheContainer, nSomeTaxIndex)
and it's in my template base class making it available to all my forms.
I pass oTheContainer because this allows you to access any type of object in which form controls might be placed, including pages of a pageframe. The 2nd parameter allows more flexibility because you can choose the tabindex you need to set focus to.
.SetFocusThisIndex
LPARAMETERS roContainer, vnIndex
LOCAL i
*
* Make vnIndex 1 if not passed
*
IF PARAMETERS() < 2 OR vnIndex = 0
vnIndex = 1
ENDIF
*
* Loop through the container object and find the match.
*
WITH roContainer
FOR i = 1 TO .ControlCount
IF NOT INLIST(UPPER(.Controls[i].Class), ;
"LABEL", "CONTAINER", "SHAPE", "PAGEFRAME")
*
* Make sure it's not in above list.
*
IF PEMSTATUS(.Controls[i], "TabIndex", 5)
*
* Make sure it has a tabindex property
*
IF .Controls[i].TabIndex = vnIndex
.Controls[i].SetFocus()
ENDIF
ENDIF
ENDIF
ENDFOR
ENDWITH
This ought to do it for you.
Steve
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only