DEFINE CLASS GridColumn AS Column lUpdateCaption = .f. PROCEDURE UpdateCaption This.DynamicCurrentControl = "IIF(This.UpdateCaption(),'Control1','Control1')" This.lUpdateCaption = .t. ENDPROC ENDDEFINEThen 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 ENDFORThen 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. ENDWITHThanks for your approach--this shows that we can solve a problem in two differnt ways!