[英]How to programmatically add a Tab to TabControl with a ListView control docked inside it?
I'm using Visual Basic 9 (VS2008)我正在使用 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. Tab 必须有一个停靠在其中的 ListView 控件。
How to programmatically add a Tab to TabControl with a ListView control docked inside it?如何以编程方式将 Tab 添加到 TabControl 并将 ListView 控件停靠在其中?
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.