Skip to content

Problem with TabControl - dynamic tab pages #1135

Description

@itg-assistant

Matthew Ferry asked 2017-09-30 21:15:32 UTC

Hi - in my project I need to dynamically create tab pages in a tab control.

Adding them dynamically works beautifully.  However what I have noticed is that once you add them - the content area / client area of the tab that is shown is the last tab page added, and the "selected" tab is usually the first page added.  And once that happens you can't seem to reconcile it with code.  The user has to click on the tab whose content is showing, and then other tab page clicks start to work as expected.

That may be a convoluted explanation.  Please see the attached project sample, and follow these steps.

Steps

  • Click "Tab Config 1" or "Tab Config 2" button.

  • Tabs are dynamically cleared and then added.

  • Observe the results

  • Expected result - the tab page that is highlighted should be the same tab content shown.

  • Actual result - the last tab page's content is shown and the first tab page is highlighted.

After that - according to my understanding of the methods I have coded - the buttons "Select Top Tab" and "Select Bottom Tab" should do as they are named. However - they do not.  It seems the tabs and their associated content are out of sync.  The situation seems to correct if the user first clicks the tab whose content is actually displayed (which is usually the bottom tab) - then after that further tab clicks are respected.

Am I doing something wrong - or is there a different way to use the methods?  I have tried .SelectTab, .SelectedTab, and .SelectedIndex - and all combinations thereof.

Any help would be greatly appreciated - and thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is broken or behaving unexpectedly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions