General information
Category:
Forms & Form designer
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.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only