Link to home
Start Free TrialLog in
Avatar of phoenixcs
phoenixcs

asked on

Creating Many Controls at Runtime in VB6

I am writing an application in VB6. As part of a form I have an indefinite number of tabs (chair1, chair2 etc) which should each present the same set of controls. Each tab (set of identical controls) will store different data.
 
I get the feeling I'm overlooking something obvious, but is there really no neat neat way or replicating all those controls (i.e. from a 'template frame' at runtime for each new tab created? (I do not want to emulate the switching of tabs by reloading each tabs different set of data into the same controls as the user switches between tabs). As far as my knowledge suggests the only way for me to do this at runtime (i.e. but not creating tons of copies of the these controls & showing/hiding them) is by creating and positioning them all *one by one* through code (using the Load statement etc). Can I not somehow replicate the picture box/frame they are all contained within! This does not seem to work but is really what I want to do!
 
Any help would be greatly appreciated, however please do not let me waste your time. Thank you.
SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of phoenixcs
phoenixcs

ASKER

PaulHews - Thank you very much for your help. What you described as your recommended solution is what I was trying to avoid, though I fully accept it is possibly the most appropriate from a range of limited solutions.
I very much like your custom control idea, I have seen this done (i.e. complete programs with each 'screen' consisting almost entirely of custom controls) but it did not occure to me that this could be a solution to my problem.

luthv - I accept your point and I was beginning to come round to this idea myself despite the fact that I stated I wanted to try and avoid this. I have been thinking about how to make the best use of resources and I suppose your suggestion is the most applicable.

I do like the custom controls idea - it seems to follow all this containment/encapsulation/'neat coding' ideas, but in this case I believe it would put more strain on the system. Instead I will use a recordset and load data into the same set of controls.

I am a little lost with awarding the points. Both of you have given me valuable advice... and though I am leaning towards luthv answer I did say in my question that 'I do not want to emulate the switching of tabs by reloading each tabs different set of data into the same controls as the user switches between tabs'. Would you both be happy if I split the points 125/125?

This is the first time I have ever got round to posting a question on EE and I am very impressed... I will be trying to earn some points (or maybe, depending on time, cheat and buy some) so I can easily gain access to more of the knowledge available here!

Lastly, I am a student (just finished A-levels) and will probably not get the time, but would you recommend I try and move over to .NET or stick with VB6 as long as I am happy? Thanks.
I guess I miss the point in your question about not wanted to emulate switching tabs, if not, my answer would be 'Yes you have missed something obvious, since you already answered your own question' :)

As for moving .NET, it's a long debate as not everyone agreed to one point over another, for me, I use both, and from time to time the knowledge you gain in VB6 will make a great benefit in .NET and vice versa (If you've heard about VBCorlib project, that attemps to port .NET mscorlib to VB6 classes with same functionality, then you'll know what I meant).
And again you already answered your own question, as long as you're happy then that's the most important thing
phoenixcs however you want to deal with the points is fine by me.  And luthv, I haven't seen your contributions on this board before this, but I sincerely hope we see more.  :)
Hope your happy with the points gentlemen (if your are indeed both gentlemen...) ... I figured that was fair. Thanks a lot for the help, Regards. Tom