>I generate and format the columns of a grid based on a DBF. Now i want to add some code into de Click event of each header. How can I do that programmaticaly if the methods are read only when the form is runing?
You have to add the code at design time. Here is a little technique that you can use to make desigining this easier.
First, you'll need a Header class, put this in a PRG somewhere:
define class MyHeader as header
proc Click
this.parent.parent.HeaderClicked(this)
endproc
enddefine
Now, in your grid class, create a "HeaderClicked()" method and accept the passed Header. Also, make sure to loopthrough every column, remove Header1, and add an instance of MyHeader called Header1.
Then, whenever you want to add code to the Click() event of your headers, you do not need to create a new header class and have it waste space in a PRG somwhere. YOu can add code to HeaderClicked() in the instance of the grid, plus, since you know what header was clicked, you can do conditional code for each one.
Its flexible and easy to maintain.