簡體   English   中英

如何以編程方式將 Tab 添加到 TabControl 並將 ListView 控件停靠在其中?

[英]How to programmatically add a Tab to TabControl with a ListView control docked inside it?

我正在使用 Visual Basic 9 (VS2008)

我想在用戶單擊“添加選項卡”按鈕時創建新選項卡。

Tab 必須有一個停靠在其中的 ListView 控件。

如何以編程方式將 Tab 添加到 TabControl 並將 ListView 控件停靠在其中?

它會像這樣......

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM