Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid classes and Header method code
Message
De
03/12/1999 05:22:41
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
03/12/1999 04:35:13
Sam Trenchard
System Support Services
London, Royaume Uni
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00297240
Message ID:
00298327
Vues:
34
>Grid column header click methods continued...
>I just want to put single line method on each header like
>
>this.parent.parent.setorder(this,this.parent.controlsource)
>
>the setorder method of the grid i have already written. it accepts the header object reference and the control source and checks to see it it can find an index tag for expression matching or containing the control source name. all this is ok.
>
>I would prefer not to have to write a builder ( i havn't done one yet so learning curves...). I you write the code todefine a column class how do you instantiate it at run time within a grid ?
>
>I have found the control.writemethod in the help but cannot work out how you actualy use it. it says only available at design time in which case how can the object have an object reference to use ? I must be missing something here.


Sam,
Download "gridx.zip" from files\classes section. You'll see how header class is changed.

Writemethod only works at designtime (also means creation time of object). You can use it with builders and they're not really things so hard. Here is a very simple "builder" :
-Create a form and add controls to it - n textboxes, a dummy commandbutton with default "Command1" name
-Go and write click code to button :
wait window "I got focus. My name is : "+this.name timeout 1
-Now select all (or few) textbox controls
-Go to command window "modi comm test" and code these :
aselobj(aMyForm,1) && Selected controls' container array
aselobj(aMyControls) && Selected controls' array
lcMethodCode = aMyForm[1].Command1.ReadMethod("Click")
for ix = 1 to alen(aMyControls,1)
if aMyControls[ix].baseclass = "Textbox"
aMyControls[ix].WriteMethod("Gotfocus",lcMethodCode)
endif
endfor

-Run it. You're done :) Run form or check textboxes' gotfocus code.

Here is a small prg I use for grids (never had a need to register as a builder so doesn't come up with rightclick but I run it from command window after selecting my grid(s)):
LPARAMETERS lcOldClass, lcNewClass, lcClassLib, lcApplyTo, lcKeepProperty, lcParams
*
* Quick and dirty builder for grid columns(ix).controls
* gridbuild(lcOldClass, lcNewClass, lcClassLib [,lcApplyTo] [,lcKeepProperty] [,lcParams])
* Author : Cetin Basoz - simple tasks library
* lcOldClass = Class to change ie: header
* lcNewClass = New Class ie: myheader
* lcClassLib = vcx or prg containing definition - if prg extension is required
* lcApplyTo  = Apply to columns list ie: 1,4,5 - all assumed if empty or ignored
* lcKeepProperty - A property to keep as is if any ie: Caption
* lcParams - Params passed to new class if any - ie : lnLeft, lnTop
*
* Sample calls :
* 1)Replace all header class with myheader class (from myheaderset.prg) and keep caption property
* =gridbuild("header","myheader","myheaderset.prg",,"caption")
*
* 2)Replace all textbox class with mytextbox class (from myclasses.vcx)
* =gridbuild("textbox","mytextbox","myclasses")
*
* 3)Replace all textbox class with mytextbox class (from myclasses.vcx) in columns 1,3,5
* gridbuild("textbox","mytextbox","myclasses","1,3,5")
*
* Select one or more grids on form and call
*
IF type("lcOldClass") # "C" ;
    or type("lcNewClass") # "C" ;
    or type("lcClassLib") # "C"
  OR empty("lcOldClass") ;
    or empty("lcNewClass") ;
    or empty("lcClassLib")
  WAIT window nowait "Required params missing."
  RETURN
ENDIF

lcApplyTo = iif(type("lcApplyTo")#"C","0",lcApplyTo)
lcKeepProperty = iif(type("lcKeepProperty")="C",lcKeepProperty,"name")
lcParams = iif(type("lcParams")="C",","+lcParams,"")
IF ratc(".prg",lcClassLib)>0
  IF !upper(lcClassLib)$set("Procedure")
    SET proc to (lcClassLib) additive
  ENDIF
ELSE
  IF !upper(lcClassLib)$set("classlib")
    SET classlib to  (lcClassLib) additive
  ENDIF
ENDIF
ASELOBJ(oGrids)
FOR each oGrid in oGrids
  IF !oGrid.baseclass = "Grid"
    LOOP
  ENDIF
  FOR each oColumn in oGrid.columns
    IF lcApplyTo=="0" or inlist(oColumn.columnorder, &lcApplyTo)
      FOR each oControl in oColumn.controls
        IF upper(oControl.class) = upper(lcOldClass)
          lcKeepName = oControl.name
          lcKeepPropValue = oControl.&lcKeepProperty
          oColumn.removeobject(lcKeepName)
          oColumn.addobject(lcKeepName,lcNewClass &lcParams)
          WITH eval("oColumn."+lcKeepName)
            .&lcKeepProperty = lcKeepPropValue
          ENDWITH
        ENDIF
      ENDFOR
    ENDIF
  ENDFOR
ENDFOR
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform