Tabpage add/remove

G

Guest

I knew that "Hide" doesn't work with Tabpage if I want to hide it. I should
use Remove/Add. But I have some other controls in the tabpage which I don't
want to use code to dynamiclly create them. If I use remove to remove that
tabpage and later use add to add it back in, I have to write code to create
all the controls inside that tabpage, otherwise it will be a blank page.
What can I do to avoid it? Thank you for your time and help.
 
C

Claudio Grazioli

I knew that "Hide" doesn't work with Tabpage if I want to hide it. I should
use Remove/Add. But I have some other controls in the tabpage which I don't
want to use code to dynamiclly create them. If I use remove to remove that
tabpage and later use add to add it back in, I have to write code to create
all the controls inside that tabpage, otherwise it will be a blank page.
What can I do to avoid it? Thank you for your time and help.

Instead completly removing the TabPages use some kind of a TabPageManager.
This TabPageManager is a class having a collection of all your TabPages.
When you have to show a TabPage you get it from the TabPageManager and add
it to the TabControl. So if you remove a TabPage from the TabControl it
still exists in the TabPageManager. So the next time you have to show the
removed TabPage you get it again from the TabPageManager and add it to the
TabControl.

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top