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

Class Creation Order 1

Status
Not open for further replies.

megmogg

Programmer
Jul 14, 2005
76
GB

Hi All

I have a class with 4 combo boxes in it (container).

They are linked by their data, i.e when you select something in the first one, it populates the second combo and so on.

My question is....do they get created or fired in any particular order.

The second combo box INIT event fires before the first combo box.

So then I put a messagebox in the INIT of the whole class and still the second combo box init fires first.

Can I alter this anywhere? I am using VFP8 and used the IDE to develop the class.

Thanks
 
The second combo box INIT event fires before the first combo box.

Code that relies upon the order in which objects are instantiated is not very robust.

A better solution would be to put the code that sets the RowSources for the dependent combo boxes in the container's Init(). That way, you can be sure that all the combos have been instantiated since the container's Init() fires after the inits of all the contained controls.



Marcia G. Akins
 

Thanks for the reply.

Know what you mean.

But the container class INIT is not firing before the 2nd combo box. This is what I cannot understand.

The 2nd combo INIT is firing first before anything else at all.

 

But the container class INIT is not firing before the 2nd combo box.

That's what you would expect. In general, the contained controls get instantiated before their container.

As Marcia says, if you put the code in the container's Init, you can be sure that it will execute after all the combo boxes have been instantiated. This is what you want. It means that you can populate the combo boxes explicitly, in any order you like.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 


Thanks for the reply.

All the combos are linked, so I want to populate them in order.

Each combo does a pass through query to a SQL server and creates a local cursor of data. Therefore I do this on every combo init. However, as each combo depends on another as they are linked, it crashes.

What would be the best way to get around this issue?

Many Thanks

 
Meggmog,

It took me a while to catch on that objects in a form get instantiated (INIT'd) from the innermost to the outermost. I believe that the "tie-breaker" is the tab order of creation - the last object added gets INIT'd first.

Steve

 

Thanks guys for the responses.

will sort it out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top