>PUBLIC oManipulador as Manipulador > >*!* - Instancia o objeto manipulador >oManipulador = CREATEOBJECT("Manipulador") > > >loGrid = SFT.PAGEFRAME1.PAGE1.CONT1.GRID1 > >* Set the ControlSource for each column >*loGrid.Column1.ControlSource = "FI.ALTURA" >*loGrid.Column5.ControlSource = "FI.ESPESSURA" >*loGrid.Column8.ControlSource = "FI.LARGURA" >*loGrid.Column9.ControlSource = "FI.PARTES" > > >* Bind the event to Column1 >BINDEVENT(loGrid.Column1, "AfterRowColChange", oManipulador, "CalculateTotal") > >* Bind the event to Column5 >BINDEVENT(loGrid.Column5, "AfterRowColChange", oManipulador, "CalculateTotal") > >* Bind the event to Column8 >BINDEVENT(loGrid.Column8, "AfterRowColChange", oManipulador, "CalculateTotal") > >* Bind the event to Column9 >BINDEVENT(loGrid.Column9, "AfterRowColChange", oManipulador, "CalculateTotal") > >DEFINE CLASS Manipulador AS Session >LPARAMETERS nColIndex > >* Define the event handler method directly >PROCEDURE CalculateTotal > ? "CalculateTotal method called" && No message was return ?? > loGrid.Column13.text1.value = VAL(loGrid.Column1.text1.value * loGrid.Column5.text1.value * loGrid.Column8.text1.value * loGrid.Column9.text1.value) > >ENDPROC >enddefine >>
?BINDEVENT(loGrid.Column5, "AfterRowColChange", oManipulador, "CalculateTotal")Should be 0, nothing bound
?BINDEVENT(loGrid, "AfterRowColChange", oManipulador, "CalculateTotal")The parameter of AfterRowColChange should be the new column for all I know.
?BINDEVENT(loGrid, "BEFORERowColChange", oManipulador, "SomeMethod")to store the old column
Proce init THIS.ADDPROPERTY("gnLastCol",0) Proce BeforeRowColChange LPARA tnLastCol THIS.ADDPROPERTY("gnLastCol",tnLastCol) Proce AfterRowColChange LPARA tnNewCol IF INLIST(THIS.gnLastCol,1,5,8,9) THEN This.Column13.text1.value = VAL(loGrid.Column1.text1.value * loGrid.Column5.text1.value * loGrid.Column8.text1.value * loGrid.Column9.text1.value)...# Problems
loGrid.Column13.text1.value = VAL(loGrid.Column1.text1.value) * VAL(loGrid.Column5.text1.value) * VAL(loGrid.Column8.text1.value) * VAL(loGrid.Column9.text1.value)### And
loGrid.Column13.text1.value = FI.ALTURA * FI.ESPESSURA * FI.LARGURA * FI.PARTES
## Result of the operation*Add a help column to the cursor controlling the grid, for this example nCol13 of value ALTURA * ESPESSURA * LARGURA * PARTES *Then set like loGrid.Column9.ControlSource = "FI.nCol13" *In AfterRowColChange use a simple REPLACE nCol13 WITH FI.ALTURA * FI.ESPESSURA * FI.LARGURA * FI.PARTES IN FI# ControlSource of Column13
loGrid.Column13.ControlSource = "[FI.ALTURA * FI.ESPESSURA * FI.LARGURA * FI.PARTES]"This just calcs the result of each row. May need a refresh in AfterRowColChange. (Pro Tip: this works with every ControlSource on every object)