>Hi!
>
>I want to set the
>grid.columnX.header1.click()
>
>code at runtime How can I do this?
>
>I tried....
>
>&ctheControl="thisform.browselist.column"+alltrim(str(i))+'.header1.WriteMethod("click","thisform.sortcolumn")'
>&ctheControl
>
>All I really need is for this click event to have the code...
>thisform.sortcolumn
>
Since you really can't add code directly at runtime, the best approach would be to create a subclass of the Column and header classses that contain the necessary Click() method code, and then programatically add instances of the Column subclass to the grid or a subclass of the grid.
You'll need to programmatically define subclasses of the Column and Header class; they can't be subclassed visually (IOW, you'll have to write a .PRG file that contains the subclasses, using the DEFINE CLASS command, rather than using the Class Browser or Class Designer to maintain them in a .VCX file. You'll need to make the class definitions availale using SET PROCEDURE rather than SET CLASSLIB.)
You may want to look at some of the sample Grid classes in the Files Section here on UT to see if someone has already built something that provides the functionality you need, or at least gives you a running start on the process of creating the necessary non-visual classes.