Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
230
Shared controls disappearing when adding new tabs dynamically
posted

Hello!

I have the WinTab control initially drawn with 2 tabs and some shared controls. When I dynamically add a new tab, the shared controls disappear on all of the tabs. Any ideas as to why this is happening?  Here is my code:

 private void btnAddTab_Click(object sender, EventArgs e)
        {
            // Call BeginUpdate to prevent the display from
            // refreshing as we add individual tabs.
            // Note: This MUST be paired with a call to
            // EndUpdate below.
            tabcTest1.BeginUpdate();

            // Specify that mnemonics will be supported. If so and
            // there is an '&' in a tab's text, the following character
            // will be treated as an accelerator (i.e. the tab will
            // be activated when the user presses the 'Alt' key and
            // that character).
            tabcTest1.UseMnemonics = DefaultableBoolean.True;

            UltraTab tabAdded;
            UltraTabsCollection tabs = tabcTest1.Tabs;
            
            //create a key...which I also use for the tab title in this test code
            int tabCount = tabs.Count;
            tabCount++;
            String newTab = "tab" + tabCount.ToString();

            // Add a tab to the Tabs collection
            tabAdded = tabs.Add(newTab, newTab);

            // Select the 'options' tab by setting the SelectedTab
            // property. This will raise the ActiveTabChanging,
            // ActiveTabChanged, SelectedTabChanging and
            // SelectedTabChanged events. It will also cause
            // the 'options' tab TabPage to be made visible and
            // the tab to scroll into view.
            tabcTest1.SelectedTab = tabs[newTab];

            // Give the tab control focus
            tabcTest1.Focus();

            // Call EndUpdate to allow the display to refresh
            tabcTest1.EndUpdate();

        }