Reputation: 3434
I'm using Visual Basic 9 (VS2008)
I want to create new Tabs as and when the user clicks an Add Tab button.
The Tab must have a ListView control docked inside it.
How to programmatically add a Tab to TabControl with a ListView control docked inside it?
Upvotes: 1
Views: 10685
Reputation: 20794
It will go something like this...
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
// Create the listView
Dim lstView As New ListView()
lstView.Dock = DockStyle.Fill
lstView.Items.Add("item 1") //item added for test
lstView.Items.Add("item 2") //item added for test
// Create the new tab page
Dim tab As New TabPage("next tab")
tab.Controls.Add(lstView) // Add the listview to the tab page
// Add the tabpage to the existing TabCrontrol
Me.TabControl1.TabPages.Add(tab)
End Sub
Upvotes: 4