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?
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?
Yes, I think you'll need a ListBox control on each tab. If they have the same data you can use the same DataSource for both though.
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.
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). In the end though, you'll probably find it easier to just have two ListBox's with the same data source.
EDIT: Please don't follow any of the quick-n-dirty unconventions in this sample code, but this'll show you how easy it is to just swap the Parent control for your ListBox instance.
http://jmdavidson.googlepages.com/WindowsFormsApplication2.zip
Essentially, it's:
listBox1.Parent = tabControl1.TabPages[1];