Binding to the Valid event

As with so many things in Visual FoxPro, binding to the Valid event isn't as straight forward as one may wish to. When binding to a control in a grid, Visual FoxPro calls the delegate object only when the grid control contains user defined code in the Valid event at some point in the class hierarchy. This code doesn't have to do anything and can be a plain comment. Visual FoxPro needs the user-defined code as a binding place, so its mere existence is sufficient.
The following sample demonstrates this behavior. No matter how you navigate in the grid
or what values you change, the only Valid event you ever see is the one from column 2:

* Binding to the Valid event of a grid control is only
* possible if you use a subclassed control with code in
* the valid event.

Public goForm
Create Cursor Test (cField1 C(10), cField2 C(10))
Insert into Test Values ("one","two")
Insert into Test Values ("three","four")
Go top
goForm = CreateObject("Form")
goForm.grd.Visible = .T.
goForm.Left = 200

Define Class MyGrid as Grid
ColumnCount = 2
Procedure Init
This.Columns(2).Text1.Visible = .T.
BindEvent( ;
This.Columns(1).Text1, "Valid", ;
This, "ColumnValid" ;
BindEvent( ;
This.Columns(2).Text1, "Valid", ;
This, "ColumnValid" ;
Procedure ColumnValid
Local laSource[1]
Activate Screen
? Sys(1272,laSource[1])

Define Class MyTextbox as TextBox
Procedure Valid