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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Altering names in a form class

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
GB
I have a form class EnqForm which is used as the basis for several forms which offer different sorts of enquiries.

This form class includes a grid in which the results of an enquiry may be displayed; its name is at present grdresult. I would like to change the name of this grid (in Enqform) in order to be consistent with another form class.

However, if the name of the grid is changed, this upsets the existing forms which have been based on Enqform. When I try to modify such a form (say enqsales), VFP correctly reports that the parent field of several records are referring to an unknown member, grdresult.

I could indeed open each of the relevant .scx files as a dbf, and change the values in the various memo fields. However even locating such fields is rather laborious.
Is there any way round this? Or should I have stabilised the design of my form class before basing forms on it!

Thanks.
 
However, if the name of the grid is changed, this upsets the existing forms which have been based on Enqform. When I try to modify such a form (say enqsales), VFP correctly reports that the parent field of several records are referring to an unknown member, grdresult.

Andrew, are you sure that's what's happening?

In general, you should be able to change the name (or other properties) of any control at the class level, and the change will be reflected down the class hierarchy. There should be no reason to see an error message.

Of course, if you have any existing code that references the control in question, that code will need editing. But that's not the case here, if I've understood your question correctly.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike

In my form enqsales, I have specified the number of columns (7) in grdresult, and defined some properties. So, for example, the textbox which exists in Column 6 appears as a record in enqsales.scx, and its parent in this record has a value enqsales.grdResult.Column6. And this is why VFP complains when I try to modify the form

Andrew
 
I see what you mean, Andrew. This is perhaps a (slightly) special case, in that it is the name of a container that has changed, and the old name is referenced from the Parent of one or more of its members.

Sorry I can't suggest an easy solution. If I was in this situation, I would be inclinded to write a program that opens each of the SCXs in turn, and searches all of the Parent fields for the old class name. But there might well be a better way.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
You perfectly describe why you don't change names in base forms. Existing code in it and subclassed forms needs to be adjusted. Solve your problem in another way.

Why do you think you need the name change?
Consistentcy of names is of less importance than working code. I wouldn't go the route of search&replace, that's a poor choice to get things working again.

What you rather need is a refactoring. Your base class is too specialised, if you need a change at a subclass level. So your baseclass needs a base class simpler than it and a branch of classes should inherit from that, for example. Howw to refactor is a thing to think about in more detail.

Bye, Olaf.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top