so I have a Homepage on one of the TabPages on winform TabControl. I have a button, that adds a new tab using this Tabs.TabPages.Add(\"Homepage\");
But TabP
You can't clone a tabpage so easily. One can try but the recommended way is:
Create a UserControl and add all the controls you want on your page. Make it Dock=Fill
and add any code that connects the controls. You can layout as freely as you would in a form or a tabpage..
Whenever you want another page of this type, add a new tabpage and add an instance of the UserControl
to its Controls
collection.
Note: All controls on your UserControl
by default are private
. This is not really different from placing them on the tabpage directly. But now they are private members of the UC class, so your form and its code can't access them.
Looks like a problem when you're new to it. But if you look at it right, it is a good oportunity to create a leaner & cleaner interface.
Solution 1: Change the control modifiers to public
as needed
Solution 2: Add properties to expose those data you really want to expose.
Also note: You can do all layout but can do so only in the UC designer. After adding to a form or tabpage there will be no embedded designer..