Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

textbox in pageframe

Status
Not open for further replies.

cjulio

Programmer
Aug 14, 2002
114
PT
how can i set focus to the first element on a page (textbox, combobox,...) without nowing its name

it is like this

i click in a botton that activates a page in a pageframe that page i dont now what is the name of the first text box how can i set focus to that same textbox

thisform.pageFrame1.pages(thisform.pageFrame1.ActivePage).setfocus does not work.
 
One way to do this is to spin thru each object on the page frame until you find the one with a tabindex (property) of 1. Then set that a using setfocus.

Code:
FOR EACH loTxt IN THISFORM.pgfMain.page1.objects
   IF INLIST(UPPER (loTxt.baseClass),"TEXTBOX","EDITBOX","LISTBOX")

      * add code to check for tabindex = 1
      IF .T.
         lcCmd = "THISFORM.PgfMain.page1." + loTxt.Name + ".SETFOCUS()"  
         &lcCmd
      ENDIF
   ENDIF
ENDFOR


This code is not fully complete, and I have not tested it, but I think it will give you enough to get going. Let us know if you need more assistance.



Jim Osieczonek
Delta Business Group, LLC
 
Is the focus on the page itself? If so you can just issue:

KEYBOARD '{TAB}'


Jim
 
the tab does not work because i have the tabs off

why doesn't this work

nomepagina = "page4"

nomepaginaobj = "THISFORM.pageFrame1." + ALLTRIM(nomepagina) + ".OBJECTS"

FOR EACH loTxt IN &nomepaginaobj

IF INLIST(UPPER(loTxt.baseClass),"TEXTBOX","EDITBOX","LISTBOX")

and the if instruction gives me an error
 
ok now it works

nomepagina = "page4"

nomepaginaobj = "THISFORM.pageFrame1." + ALLTRIM(nomepagina) + ".OBJECTS"

FOR EACH loTxt IN (nomepaginaobj)

IF INLIST(UPPER(loTxt.baseClass),"TEXTBOX","EDITBOX","LISTBOX")

the "&nomepaginaobj" as to be "(nomepaginaobj)
 
Jim, instead of
Code:
lcCmd = "THISFORM.PgfMain.page1." + loTxt.Name + ".SETFOCUS()"

try
Code:
lcCmd = "THISFORM.PgfMain.page1." + loTxt.Name + ".Click"

Gerardo Czajkowski
ltc.jpg
 
jimoo said:
Out of curiousity, why do you prefer the click to the setfocus?
Personally, I prefer it over setfocus because it triggers the ACTIVATE event and I usually add code there on pageframes.
BTW, the line can also be
Code:
lcCmd = "THISFORM.PgfMain.page1." + loTxt.Name + ".Activate"

Gerardo Czajkowski
ltc.jpg
 
Geraldo,

This may be handy in some instances, but in the instance descriped the page frame would alread have focus. This could result in unnessarily executing the code in the ACTIVATE event more than once.



Jim Osieczonek
Delta Business Group, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top