By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,462 Members | 1,369 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,462 IT Pros & Developers. It's quick & easy.

Howto create tabpages dynamically?

P: n/a
Hi NG,

I am looking for a good way to dynamically generate a bunch of TabPages.

I have a list of more or less identical object. For each of these objects I
need a user interface. My thought is, to provide a TabPage for every object
with controls on it to interact with them. How can that be achieved
dynamically.

The only way I can think of to do this is to prepare the max needed TabPages
and keep them in a list. But this would mean a lot of manual work. I am sure
there is a better way to do this. Is it possible to just define one TabPage
with the form designer and then inherit from it?

Thanks for hints and suggestions.

Rainer
May 17 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I have read several posts regarding the difficulties of populating a
TabControl with objects that inherit from TabPage. It can probably be
done, but all I've read about are problems.

There is another approach: you could create a factory method for each
TabPage layout. Pass the object you want to show on the UI, choose the
correct factory method based on the object, and the factory returns you
a TabPage all ready to go, as it were.

Then you just have to add the TabPage to the TabControl's page
collection and it should appear to the user.

May 17 '06 #2

P: n/a
Hi Bruce,

thanks for your reply.
There is another approach: you could create a factory method for each
TabPage layout. Pass the object you want to show on the UI, choose the
correct factory method based on the object, and the factory returns you
a TabPage all ready to go, as it were.

Then you just have to add the TabPage to the TabControl's page
collection and it should appear to the user.

This sounds like a good idea, but still means quite a bit of work. (I am a
lazzy person you must know ;-)
Following this sugestion, means I would have to create each control on the
TabPage at run time, do the right possitioning and then bind the controls to
the objects properties (how can I do this?) .

Is there a way to do a deep copy of a tabpage? This way I could design one
as a "master TabPage". Then the factory method could copy the controls for
the new TabPage from the master....

Regards
Rainer
May 17 '06 #3

P: n/a
Hi,

"Rainer Queck" <Ra****@noemail.noemail> wrote in message
news:OV**************@TK2MSFTNGP05.phx.gbl...
Hi Bruce,

thanks for your reply.
There is another approach: you could create a factory method for each
TabPage layout. Pass the object you want to show on the UI, choose the
correct factory method based on the object, and the factory returns you
a TabPage all ready to go, as it were.

Then you just have to add the TabPage to the TabControl's page
collection and it should appear to the user. This sounds like a good idea, but still means quite a bit of work. (I am a
lazzy person you must know ;-)


It's not that difficult, you said your objects were kind of similar , if so
you can have a predefined factory method that returns a tabpage with these
common fields (you can cut & paste it from the designer's generated code)
then the correct method factory fill up the rest of the controls, most
probably you have a small finite number of objets you want to handle this
way so you can define the code manually.
Is there a way to do a deep copy of a tabpage? This way I could design one
as a "master TabPage". Then the factory method could copy the controls for
the new TabPage from the master....


IMO this will be more complex to build and more slow to run
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
May 17 '06 #4

P: n/a
Hi Ignacio,
It's not that difficult, you said your objects were kind of similar , if
so you can have a predefined factory method that returns a tabpage with
these common fields (you can cut & paste it from the designer's generated
code) then the correct method factory fill up the rest of the controls,
most probably you have a small finite number of objets you want to handle
this way so you can define the code manually.

I was already putting this way in considerations. For the moment I found a
easier (not that beautiful but operatable) way.
- create TabPage
- create PropertyGrid
- add PropertyGrid (Fill) to TabPage
- add TabPage to TabControl.
As I said, not that beautiful, but it works for the moment. Through the
property grid I can now work on my objects ;-)

Regards
Rainer
May 18 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.