How can add new tab on a tab page control by clicking a child node in a treeview?

Edited 3 Years Ago by pritaeas: Moved.

Hi,

You need to declare your tabpage as the new one, give this page a name and add that new tabpage to the Tabpagecontrol.
Add this code to the Listview selectedindexchange event.

Try this and show us your codes.

I think i got it but my problem is that. The form inside the tab page are movable. And when i click the node to add pages, it does not focuses on the page i selected. What i mean is that if i clicked the "Borrow" child node. The Tab Page named "Borrow" should be selected.

These are my codes.

Public Class frmMain

    Private Sub treeviewMain_NodeMouseDoubleClick(sender As Object, e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles treeviewMain.NodeMouseDoubleClick

        Dim page As Integer = tabMain.TabPages.Count
        Dim tabpage As New TabPage
        tabpage.Text = treeviewMain.SelectedNode.Text.ToString()

        If (treeviewMain.SelectedNode.Text.ToString() = "Return") Then

            tabMain.TabPages.Add(tabpage)
            Dim frm As New frmReturn
            frm.TopLevel = False
            frm.Parent = tabMain.TabPages(page)
            frm.Show()

        ElseIf (treeviewMain.SelectedNode.Text.ToString() = "Borrow") Then

            tabMain.TabPages.Add(tabpage)
            Dim frm As New frmBorrow
            frm.TopLevel = False
            frm.Parent = tabMain.TabPages(page)
            frm.Show()

        ElseIf (treeviewMain.SelectedNode.Text.ToString() = "OPAC") Then

            tabMain.TabPages.Add(tabpage)
            Dim frm As New frmOPAC
            frm.TopLevel = False
            frm.Parent = tabMain.TabPages(page)
            frm.Show()

        End If
    End Sub
End Class

THANKS!!

Attachments Untitled.jpg 207.11 KB
This article has been dead for over six months. Start a new discussion instead.