Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grids
Message
From
09/07/1999 10:07:19
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
09/07/1999 09:53:41
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Re: Grids
Miscellaneous
Thread ID:
00239393
Message ID:
00239402
Views:
10
>I'm running visual foxpro 5.0 in a win95 operating environment. Is there any way to programatically code the grid column/ header / and textbox events in a grid?
Yes :) You can create your column, header nonvisually and replace current grid's with the ones you create. You could also do this at designtime via a builder that would change columns and headers to your classes. And in the meantime you would also change default textbox class with yours. For header changing you can check multiselectgrid class in files\classes section. Here is a simple prg style builder to change things at designtime (never had a necessity to register this builder) :
LPARAMETERS lcOldClass, lcNewClass, lcClassLib, lcApplyTo, lcKeepProperty, lcParams
*
* Quick and dirty builder for grid columns(ix).controls
* gridbuild(lcOldClass, lcNewClass, lcClassLib [,lcApplyTo] [,lcKeepProperty] [,lcParams])
* 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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform