Jump to content

Preciso de ajuda nos TabControls


yekxmerr
 Share

Recommended Posts

Boas, estou com um pequeno problema. O meu programa tem um formulário inicial, e tem um menustrip que abre os restantes formulários. Hoje decidi adicionar um tab control ao menu inicial e queria que os outros formulários abrissem dentro de esse tabcontrol de uma forma idêntica aos separadores do firefox.

Tenho o seguinte código no menustrip:

    Private Sub CriarNovoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As

        Dim frmUser As New Aluno

        frmUser.TopLevel = False

        frmUser.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle

        Me.TabControl1.TabPages(0).Controls.Add(frmUser)

        frmUser.Show()

    End Sub

Alguem tem uma solução para os restantes formularios ? Isto é, queria carregar num butão e apareçer uma nova tab com o formulario la dentro. Cumps

Cumps

Link to comment
Share on other sites

Não é visível a todos ... aqui fica o código do link:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim frm As New Form1
        frm.TopLevel = False
        frm.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedToolWindow
        frm.Dock = DockStyle.Fill
        AddHandler frm.FormClosed, AddressOf frm_FormClosed

        Dim tp As New TabPage
        frm.Tag = tp
        tp.Controls.Add(frm)
        frm.Show()

        TabControl1.TabPages.Add(tp)
    End Sub

    Private Sub frm_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs)
        TabControl1.TabPages.Remove(sender.tag)
    End Sub
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.