DEFINE CLASS MyHeader AS Header FUNCTION Click THIS.Parent.Parent.DoSort(THIS.Parent.ControlSource) ENDFUNC ENDDEFINE DEFINE CLASS MyColumn AS Column FUNCTION Init THIS.RemoveObject("Header1") THIS.AddObject("Header1","MyHeader") ENDFUNC ENDDEFINEWhen you generate your cursor, the grid gets populated automatically in case the ColumnCount proeprty is set to -1. However, that's not what you want. You set the ColumnCount property to 0 and populate the grid yourself. Here's how:
THISFORM.oGrid.RecordSource = "MyCursor" THISFORM.oGrid.ColumnCount = 0 FOR lnCounter = 1 TO FCount() lcObject = "Column"+Trans(lnCounter) THIS.oGrid.AddObject(lcObject,"MyColumn") THIS.oGrid.&lcObject..ControlSource = Field(lnCounter) THIS.oGrid.&lcObject..Header1.Caption = Field(lnCounter) ENDFOROf course, you now also need some code in the grid that sets the order. In the example above, I assume there is a DoSort() method.