Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding Method code to object programmatically
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00185271
Message ID:
00186065
Vues:
19
Hi,

You cannot programmatically add code to a class at run-time.

You might be able to get away with creating a VCX and class programmatically, compile it programmaticcally, SET CLASSLIB TO it, and then add it to your grid. This would only work if you run Microsoft Visual Foxpro (meaning each customer would have to have VFP installed on his/her machine) and then run the app from within VFP.

This would not work in a compiled EXE.

It also gets around the whole reason for creating classes in the first place: classes give you a place to put code that you want to reuse.

Design Patterns may be of use to you. You could use what is called a bridge pattern. Create a checkbox class that in it's InteractiveChange has the following code:

RETURN thisform.oCheckBoxBehavior.InteractiveChange(this)

Add the checkbox to the grid

In the init of the form, instantiate a class that has the behavior you want in the InteractiveChange and attach it to thisform.oCheckboxBehavior.

Now you can change the checkbox behavior by attaching a different object to thisform.oCheckboxBehavior

>
>In the init of a grid I have the following code:
>
>
>this.column1.AddObject("chk1","checkbox")
>this.column1.currentcontrol = "chk1"
>this.column1.sparse = .f.
>this.column1.chk1.visible = .t.
>this.column1.chk1.caption = ""
>
>
>I now want to add code to the InteractiveChange method of this checkbox. How do I go about doing this?
>
>Thanks,
>Paul
Rick Hodder
MCP Visual Foxpro
C#, VB.NET Developer
Independent Consultant
www.RickHodder.com
MyBlog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform