Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Command Button in Grid
Message
 
À
27/05/2004 11:21:06
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00907664
Message ID:
00907791
Vues:
13
This message has been marked as the solution to the initial question of the thread.
Hi Fabio:

Interesting angle on your solution to the problem.

What I ended up doing is subclassing the VFP column such as:
DEFINE CLASS GridColumn AS Column

lUpdateCaption = .f.

PROCEDURE UpdateCaption
	This.DynamicCurrentControl = "IIF(This.UpdateCaption(),'Control1','Control1')"
	This.lUpdateCaption = .t.
ENDPROC 

ENDDEFINE
Then I created a new method in my GRID called oGrid.UpdateCaption
LOCAL oColumn

*
* Loop through each column in the grid and update
* the caption of the control--if the custom property is set
*
FOR EACH oColumn IN This.Columns
	
	*
	* If the custom property is set to TRUE then update
	* the caption with the column's controlsource
	*
	IF oColumn.lUpdateCaption
		IF NOT EMPTY(oColumn.ControlSource)
			oColumn.Control1.Caption = EVALUATE(oColumn.ControlSource)
		ENDIF
	ENDIF
	
ENDFOR 
Then when I'm building my grid--in my case I have to build my grid dynamically from some metadata. Here is some peudo-code that I'm using:
FOR m.i = 1 to nColumsToAdd

    m.cColumnName = "Column" + ALLTRIM(STR(m.i))

    This.AddObject(m.cColumnName,"GridColumn")
    
    oColumn = This.Columns[m.i]
    
    WITH oColumn

        *
        * Remove the standard textbox that VFP adds in by default
        *
        .RemoveObject("Text1")

        if m.lCommandButton
           .AddObject("Control1","xcmdgrid")
           .UpdateCaption()
        else
           .AddObject("Control1","xtxtgrd")
        endif
        .CurrentControl = "Control1"
        .Visible = .t.

   ENDWITH
Thanks for your approach--this shows that we can solve a problem in two differnt ways!

--Paul
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform