Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Finding All Textboxes in Form
Message
De
30/08/2005 04:08:03
 
 
À
30/08/2005 02:12:22
Sunil Kejariwal
The Software Workshop
Mumbai, Inde
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 6
Divers
Thread ID:
01045035
Message ID:
01045044
Vues:
38
>If i want to set background, foreground color of all textboxes in a form as per the users selection, how can i find out all the textboxes present in a form. Is there any way to loop through all the textboxes.
>
>Can I use variables while desiging the form for the background and assign it in the loop ?
>
>Pl. help.
>
>Thanks in advance.
>
>Regards

Hi There,
While Boris advice is sufficient if all textboxes are directly on the form,
here is class that will drill down all object in nested containers,pagreames etc. ( method 'go_all_over' ) and execute another method passing each object as parameter (method 'do_the_thing')

Simply write 'do_the_thing ' method as u wish
and then run it anywhere in the form
&&Anywhere in the form
local oMyObjects
oMyObjects=createobject('myFormObjects')
oMyObjects.go_all_over(thisform)


* this class has to be added to some prg that 
* is visible to vfp, by having 'set procedure' set to it (additive)

***Class Object
define class myFormObjects as custom

  procedure go_all_over
  LPARAMETERS ParentContainer
  LOCAL i,oControl
  FOR each oControl in ParentContainer.Controls
    DO case
        CASE oControl.baseclass=="Pageframe"
            FOR i = 1 to  oControl.Pagecount
                this.go_all_over(oControl.Pages(i))
            NEXT

        CASE oControl.baseclass=="Container"
            this.go_all_over(oControl)

        CASE oControl.baseclass=="Grid"
            FOR i = 1 to  oControl.columncount
                this.go_all_over(oControl.columns(i))
            NEXT
        OTHERWISE
            this.do_the_thing(oControl) 
    ENDCASE
  NEXT
  this.do_the_thing(ParentContainer)


procedure do_the_thing
  lParameters oControl
   if oControl.baseclass='TEXTBOX'
    **Do whatever
   endif
Even better wld be to subclass it and then write 'do_the_thing' method
in subclass code , this way u can keep original class multipurpose
for another implementations of the similar type.

Class does not support collections (I am still with VFP6*SP5)
so if u have those then u should hv to do some upgrading to this class.


Rgds++
Sergio
*****************
Srdjan Djordjevic
Limassol, Cyprus

Free Reporting Framework for VFP9 ;
www.Report-Sculptor.Com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform