Add tab page with user control at runtime
Hi,
I created a user control and added it to a tab page.
If I add the tab page to the tab control using the resource editor it works.
Now I want to add the page at runtime using the following code:
Code:
TabPage myPage = new TabPage ("MyPage")
this.myTabControl.TabPages.Add (myPage)
This code adds the page to the tab control but without the user control. So the page is empty.
Can you help ?
Thanks.
Re: Add tab page with user control at runtime
You showed where you added a new TabPage to myTabControl. You did not show where you added 'a user control' to myPage.
Re: Add tab page with user control at runtime
Yeah, you're not adding the control, so of course it is not there. You need to add the control to the TabPage's Controls collection.
On the other hand, you can just add the tab page in the designer and remove it when the form loads up. This is probably preferable since you can design it visually.
1 Attachment(s)
Re: Add tab page with user control at runtime
Hi,
Attached a snapshot of the properties of a tab page.
Is it possible to specify the user control dragged into the tab page ?
Where ?
Thanks.
Re: Add tab page with user control at runtime
No, it's not. Just drag it from the toolbox.