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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I loop thru controls on a pageframe ?

Status
Not open for further replies.

TerDavis

Technical User
Sep 18, 2002
36
0
0
US
I would like to able to use generic code that would
loop thru the controls on a given pageframe and determine the type of control ...

so, something similiar to

for 1 to pageframe.page.numberofcontrols
get control reference
determine control type
if control is textbox
than dosomething
if control is comboxbox
than dosomething
etc etc
endfor

I am sure this has been done, but am relatively new to
foxpro and would appreciate some insights.
 
Here's a simple example. You'll get the idea:

WITH PageFrame.Page1
FOR i = .CONTROLCOUNT TO 1 STEP -1
STORE .CONTROLS(i) TO obj
DO CASE
CASE 'TEXTBOX' $ UPPER(obj.NAME)
*... do something

CASE 'COMBOBOX' $ UPPER(obj.NAME)
*... do something

CASE etc....
.
.
.
etc.

ENDCASE
NEXT
ENDWITH
Dave S.
 
TerDavis

You could use the SETALL functions:
THISFORM.PAGEFRAME1.PAGE1.SETALL("TextBox",.t.,"enabled")

Or you could create an array of the objects names and loop trought the array

Amembers(myArray,thisform.pageframe1.page1,2) Mike Gagnon
 
FOR EACH lo_control IN Thisform.pageframe1.page1.objects
DO CASE
CASE LOWER(lo_control.baseclass) = "commandbutton"
WAIT WINDOW lo_control.Name + " is Command Button "
CASE LOWER(lo_control.baseclass) = "label"
WAIT WINDOW lo_control.Name + " is Label"
OTHERWISE
WAIT WINDOW "Other type control"
ENDCASE
NEXT
 
HI

***************************************
** Form method "mySetting"
** to run this.. examples..
** =mySettings(This)
** =mySettings(ThisForm)
** =mySettings(ThisForm.PageFrame1)
** =mySettings(myObject)

LPARAMETERS oContainer
LOCAL oThis
IF m.oContainer.Baseclass == 'Form'
m.oContainer.LockScreen = .t.
** DO whatever you want
ELSE
** DO whatever you want
ENDIF

FOR EACH m.oThis IN m.oContainer.Controls
IF NOT m.oThis.BaseClass == 'Custom'
** DO whatever you want
ENDIF
DO CASE
CASE m.oThis.BaseClass == 'Container'
** DO whatever you want
CASE m.oThis.BaseClass == 'Pageframe'
LOCAL oPage
FOR EACH oPage IN m.oThis.Pages
** DO whatever you want
ENDFOR
CASE m.oThis.BaseClass == 'Grid'
LOCAL oColumn
FOR EACH oColumn IN m.oThis.Columns
** DO whatever you want
ENDFOR
CASE m.oThis.BaseClass $ 'Commandgroup,Optiongroup'
LOCAL oButton
FOR EACH oButton IN m.oThis.Buttons
** DO whatever you want
ENDFOR
ENDCASE
ENDFOR
IF m.oContainer.Baseclass == 'Form'
m.oContainer.LockScreen = .F.
ENDIF
**********************************************
Hope this helps you :) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top