Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add New Property To Base TextBox Class

Status
Not open for further replies.

IForgot

Programmer
Mar 20, 2002
122
0
0
US
Without creating a totally new custom class, can I just add a new property to the VFP7 existing TextBox Base Class.

I would like to add a Property to hold the TextBox's Original Value (from When method) which can be later compared against the possible New value (in Valid method). Like Marcia mentions in thread1254-812041 but not with a Custom TextBox class.

Yes I can do this with a Form Property, but it would be easier and more flexible if I could do this with a TextBox property.

Thanks,
I_Forgot
 
IForgot

No there is no way to do it. Is there a reason why you do not want to use a custom TextBox class?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Do I have a good reason for not wanting to use a Custom TextBox class? Not really.

But since the new OrigValue property could potentially be of value EVERY time I want to use ANY TextBox, it seems as though it would just be MUCH easier to change the default TextBox class instead of having to create (and remember to select) a 2nd Custom TextBox.

Thanks,
I_Forgot
 
Iforgot

If you create a custom textbox, you can specify in VFP to use that custom textbox every time you need to create a new one. Tools-Options->Field Mapping. You can map your textbox to your class.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Without creating a totally new custom class, can I just add a new property to the VFP7 existing TextBox Base Class.

Actually, you can:

in the appropriate event-method (perhaps, Init!):
Code:
THIS.AddProperty('NewPropertyName', THIS.Value)

There's also a "tag" property already there, documented "for developers to use for whatever they want
 
wgcs,
True, but that's not really persistant! I believe that's I_Forgot was really asking for. Your method would require adding that code to every instance of a textbox. :-(

Creating your own subclass is so easy and as Mike says it's trivial to make that the default so you don't "forget".

Rick
 
Making the custom subclass does indeed sound like the way to go so that the new property is available everytime I need it.

You say that making a subclass is "so easy", but my stumbling around through VFP7's various menus has not shown me how to do it.

Without taking too much of your time, can you point out to me where to look for references on how to do it?

Thanks,
I_Forgot
 
Menu -> File -> New ... -> choose Class -> click on "New File" button. Enter (or choose):
MyTextBox (really anything you want!)
TextBox
MyBaseClasses (see above - this is the VCX name - you can include a path)

Click on "OK"

Now you have a class you can modify and use as your baseclass!

Rick

 
wgcs said:
There's also a "tag" property already there, documented "for developers to use for whatever they want"
There is a 'gotcha' with the use of the .Tag property - it will only accept text strings, but in this case would provide an alternative solution for IForgot.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommander[sup]tm[/sup].com
PDFcommander[sup]tm[/sup].co.uk


 
Hello IForgot.

>> Without taking too much of your time, can you point out to me where to look for references on how to do it? <<

You may also want to take a peek at the Class Browser topic in the on-line help.




Marcia G. Akins
 
Either create a sub-class or add a property at runtime
in the texbox's init() method.

i.e.

procedure txtBox.init
this.addproperty("MyProp",somevalue)
endproc

If you sub-class the controls, you can set both
form controls and table fields(only if in a database) to
the various sub-classed controls in your custom vcx.

To make your custom control classes the default(s) in the
form designer, open the tools->options menu and select
the fieldmapping page. It's pretty intuitive from there.


Darrell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top