Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Preserving grid properties
Message
De
27/03/2004 11:07:07
 
 
À
20/03/2004 18:23:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00888244
Message ID:
00890165
Vues:
18
>Usually, I define a grid based on an alias which I can see at design and run time. However, I have a form where I am designing a grid but that grid will be bound on a cursor that I am defining in the Init() of the form. So, I have something like this:
>
>
>MESSAGEBOX(ThisForm.ControlFile.Columns(1).ControlSource)
>MESSAGEBOX(ThisForm.ControlFile.Columns(2).ControlSource)
>
>
>which gives the proper field names. Then, I assign the grid to the cursor which I just created in the Init() of the form:
>
>
>ThisForm.ControlFile.RecordSource='Control'
>MESSAGEBOX(ThisForm.ControlFile.Columns(1).ControlSource)
>MESSAGEBOX(ThisForm.ControlFile.Columns(2).ControlSource)
>
>
>Both ControlSource are now empty. Anyone can tell me the trick to preserve the grid properties?

I ´ve downloaded a grid's class from Portalfox (Luis María Guayan was its author) which has two methods.
1) PreservarColumnas()-which keeps all grid's properties
2-RestaurarColumnas() restores all grid's properties.

*-- Grid::PreservarColumnas
LOCAL lo
FOR EACH lo IN THIS.COLUMNS
STORE lo.CONTROLSOURCE TO ("lo."+lo.CURRENTCONTROL+".Tag")
ENDF
THIS.TAG = THIS.RECORDSOURCE
THIS.RECORDSOURCE=""

*-- Grid::RestaurarColumnas
LPARAMETERS lcAlias && si no está en la grilla debe especificarse acá
LOCAL lo, lc
THIS.RECORDSOURCE = IIF(NOT EMPTY(lcAlias),lcAlias,THIS.TAG)
FOR EACH lo IN THIS.COLUMNS
lc = EVAL("lo."+lo.CURRENTCONTROL+".Tag")
IF NOT EMPTY(lc)
IF NOT '.'$lc && sin alias asignado: lo asigna ahora
lc = THIS.RECORDSOURCE+'.'+lc
ENDIF
lo.CONTROLSOURCE = lc
ENDIF
ENDFOR


Working with VFP8 i add a grid based on my class, set grid properties at design time, and set form's bindcontrols=.f. and put this code in Init method works fine

*Init code
THISFORM.LOCKSCREEN=.T.
THISFORM.Migrid1.PreservarColumnas() &&to keep grid column's properties
**code to load your cursor
thisform.migrid1.restaurarcolumnas('yourcursorname')
thisfom.bindcontrols=.t.
thisform.Refresh()
thisform.LockScreen= .F.

HTH
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform