Switch panel from tabcontrol page to page problem

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

I have a tab control with 2 tabs that need to share a panel. The panel has
controls that change (Text property etc..) depending on which tab is
selected. I am trying to show the panel on the selected tab. So when
clicking tab 1, the panel shows there, and when clicking tab 2 it should
then show there.

In my tabControl1_SelectedIndexChanged event I change the Parent property of
the panel to the selected tab page. That wasn't enough, so I added
panel.Show() and panel.BringToFront(). No difference. The panel will show up
only occasionally after clicking a different tab page (like tab 3 or 4).

What am I missing here?

Tim
 
The approach is somewhat dubious, but if you absolutely must to do it this
way, instead of modifying Parent property on the panel, try doing this:
tabpage1.Controls.Remove(panel);
tabpage2.Controls.Add(panel);
 
Back
Top