Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can I add method code at runtime ?
Message
De
05/02/2001 18:20:40
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00472716
Message ID:
00472735
Vues:
38
Vlad,

Thanks. This is a good idea. That is where I was going if in fact you couldn't add the method code at run time. Now that I know you can't, I will do it the way you have suggested.


>Hi!
>
>You cannot do this in run-time, VFP does not allow to change methods code in run-time.
>
>However, you can solve this problem by easy way by making a text box class with generic functionality.
>
>Make a textbox class. Add property 'ValidationNumber'. In valid event add code:
>thisform.ValidateTextbox(this)
>OR
>this.parent.ValidateTextbox(this)
>
>In the form (or container) make above custom method and put code there:
>lparameters poTextBox
>do case
>case poTextBox.ValidationNumber = 1
>...
>case poTextBox.ValidationNumber = 2
>...
>...
>endcase
>
>This way you still will be able to put your class in run-time using addobject(), but assign the validation routine umber to the property of textbox instead of code assignment to method.
>
>HTH.
>
>>I am creating a set of text boxes, in a container, at run time, with addobject(), based on the values in a table. I am using the textbox base class as the class on which to base the text boxes. (maybe I shouldn't ?). But ideally I want each text box to have it's own custom valid method. I guess if I based it on a different subclass of textbox, it could inherit the valid, this would be better, but still might not do the trick.
>>
>>Is it possible to create the valid at runtime, per text box ? I see no
>>addmethod() method, just addproperty()
>>
>>Thanks.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform