dcsimg
Results 1 to 2 of 2

Thread: Forms at TabControl not passing values to other Form

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2019
    Posts
    1

    Forms at TabControl not passing values to other Form

    I have a tabcontrol in a mdi parent form where a put child forms into a tabpage.
    When I open other form in a child form the values of the form is not passing to the other form,

    Here's the code:

    'open a form at the tabpage of the parent form

    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load


    MainMenuStrip = New MenuStrip()


    End Sub

    Private Sub Form1ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles Form1ToolStripMenuItem.Click

    Dim frm As New Form1
    Dim tab As New TabPage
    frm.TopLevel = False
    frm.TopMost = True
    tab.Text = "Cadastro de Funcionário"
    tab.Controls.Add(frm)
    TabControl1.TabPages.Add(tab)
    TabControl1.SelectedTab = tab

    frm.Show()


    End Sub

    'open another form from the Form1. (not in a tabpage)

    Public Class Form1
    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click


    Form2.Show()

    End Sub

    'passing values of the Form2(datagridview) to the Form 1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    Dim frm As New Form1



    frm.Text_Nome.Text = Text_BuscarNome.Text
    frm.Combo_Sexo.Text = dg_ProcurarFuncionario.CurrentRow.Cells(2).Value
    frm.Text_CPF.Text = dg_ProcurarFuncionario.CurrentRow.Cells(3).Value
    frm.Text_Endereco.Text = dg_ProcurarFuncionario.CurrentRow.Cells(4).Value
    frm.Text_Telefone.Text = dg_ProcurarFuncionario.CurrentRow.Cells(5).Value
    frm.Text_Email.Text = dg_ProcurarFuncionario.CurrentRow.Cells(6).Value
    frm.Text_Salario.Text = dg_ProcurarFuncionario.CurrentRow.Cells(7).Value
    frm.Text_Data.Text = dg_ProcurarFuncionario.CurrentRow.Cells(8).Value
    frm.Lbl_ID.Text = dg_ProcurarFuncionario.CurrentRow.Cells(0).Value

    Me.Hide()

    End Sub

    Then in this last part of the code is not working, the values of the form 2 is not passing to the form1(who is in a tabcontrol).
    Can anyone help me?

  2. #2
    Addicted Member Goggy's Avatar
    Join Date
    Oct 2017
    Posts
    144

    Re: Forms at TabControl not passing values to other Form

    Dim frm As New Form1 <----- creates new instance of Form1, It does NOT use the existing instance
    Utterly useless, but always willing to help

    As a finishing touch god created the dutch

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width