Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid Preferences/Set up not staying
Message
De
19/10/1999 13:31:14
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00277024
Message ID:
00278323
Vues:
26
wow. thanks so much. I'll work with it.


>Let's make sure ;)
>
>Here is the code for the grid memento: put this code in a prg called gridmemento.prg:
>
>
>DEFINE CLASS GridMemento AS LINE
>  DIMENSION aColumnHeight[1]
>  DIMENSION aColumnWidth[1]
>  DIMENSION aColumnOrder[1]
>  nColumnCount = 0
>
>PROC GetState(toGrid)
>  LOCAL lnColumn, loColumn
>  WITH this
>       .nColumnCount = toGrid.ColumnCount
>       DIMENSION aColumnHeight[.nColumnCount]
>       DIMENSION aColumnWidth[.nColumnCount]
>       DIMENSION aColumnOrder[.nColumnCount]
>       FOR lnColumn = 1 TO .nColumnCount
>           loColumn = toGrid.Columns(lnColumn)
>           .aColumnHeight[lnColumn] = loColumn.Height
>           .aColumnWidth[lnColumn]  = loColumn.Width
>           .aColumnOrder[lnColumn] = loColumn.ColumnOrder
>       ENDFOR
>  ENDWITH
>ENDPROC
>
>PROC SetState(toGrid)
>  LOCAL lnColumn, loColumn
>  WITH this
>       FOR lnColumn = 1 TO .nColumnCount
>           loColumn = toGrid.Columns(lnColumn)
>           loColumn.Height = .aColumnHeight[lnColumn]
>           loColumn.Width  = .aColumnWidth[lnColumn]
>           loColumn.ColumnOrder = .aColumnOrder[lnColumn]
>       ENDFOR
>  ENDWITH
>ENDPROC
>
>ENDDEFINE
>
>
>Lets say that you have a form with a grid on it. Set the Name property of the grid to "oGrid". To make things simple, we will put the reference to the grid memento on the form.
>
>Create a property called oGridMemento on the form. In the init of the form, put the following code:
>
>
>*-- "this" refers to the form
>SET PROCEDURE TO GridMemento.PRG
>this.oGridMemento = CREATEOBJECT("GridMemento")
>this.oGridMemento.GetState(this.oGrid)
>
>
>In the GotFocus of the form, put the following code:
>
>
>*-- "this" refers to the form
>this.oGridMemento.SetState(this.oGrid)
>
>
>Does that make it clearer for you?
>
>Rick
>
>>Thanks Rick. I actually think I understand what you're saying :-)
>>
>>
>>>>How do you set it up so that if the user splits the grid or moves columns in a paricular order it stays? Each time a new selection is made from the 'main' form, the grid goes back to the way it was originally.
>>>
>>>The memento design pattern could be useful here: the memento design pattern is used when you need to capture a "state" within an object for later restoration.
>>>
>>>For instance, here is a class that captures the current alias setting:
>>>
>>>SELECT MyDBF1
>>>loAlias=CREATEOBJECT("AliasMemento")
>>>loAlias.GetState() && Captures state (alias)
>>>SELECT MyDBF2
>>>loAlias.SetState() && Restores state (alias)
>>>
>>>DEFINE CLASS AliasMemento AS LINE
>>>cAlias = ""
>>>
>>>PROC GetState
>>> this.cAlias = ALIAS()
>>>ENDPROC
>>>
>>>PROC SetState
>>> SELECT (this.cAlias)
>>>ENDDEFINE
>>>
>>>You could create an class that loops through the column collection of a grid, storing the state (width, order, etc) of the columns within a memento object. Instantiate and fill in the memento when the form is instaniated, and then in the GotFocus of the form, restore the grid from memento.
>>>
>>>Hope this helps,
>>>Rick
"Live Well, Laugh Often, Love Much..."
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform