How to display the same control on two different tabs?


Question

I'm using VB.NET

I need same control (ListBox) to be displayed on 2 different tabs.

Is it mandatory to create 2 different ListBox instances?

1
6
2/4/2009 8:52:31 PM

Accepted Answer

If you don't need design-time support you can simply, at runtime, change the ListBox instance's Parent from one tab to the other (making sure to set the positioning appropriately, of course).

Essentially, it's:

listBox1.Parent = tabControl1.TabPages[1];

In the end though, you'll probably find it easier to just have two ListBox's with the same data source.

13
1/8/2018 9:31:39 PM

If you want full designer support, you'll need two boxes. If doing it in code is enough, you can create a single listbox on form load, and manually add a reference to it to each tab page.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon