CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2003
    Posts
    100

    Unhappy 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.

  2. #2
    Join Date
    Oct 2004
    Location
    Rocket City
    Posts
    220

    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.

  3. #3
    Join Date
    Jun 2008
    Posts
    2,477

    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.

  4. #4
    Join Date
    Apr 2003
    Posts
    100

    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.
    Attached Images Attached Images

  5. #5
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Add tab page with user control at runtime

    No, it's not. Just drag it from the toolbox.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured