Problem when sending DataGridView data from the child form to the parent form. Nothing happens

0

I need to send a line from a datagrid view of a child form to the text boxes of a parent form. After sending them, the child form must be closed automatically.

I have a child form that I send to call from a parent form with the following code:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles 
Button1.Click
Dim S As New SelUN 
    S.MdiParent = Me.ParentForm
    consultar(S.DataGridView1)
    S.Show()
    S.DataGridView1.Columns(0).HeaderText = "Código"
    S.DataGridView1.Columns(0).Visible = False
    S.DataGridView1.Columns(1).HeaderText = "Nombre"
    S.DataGridView1.Columns(1).Width = 438
 End Sub

So far everything is going well and the child form shows no problem, in addition the parent form stays open while the child form is opened, which is how I occupy it.

In the child form, I have a DataGridView, to which I need to pass the columns of a line to the TextBox of the Parent form. I do it with this code:

Sub mostrar_datos()
    Try
        With DataGridView1

            AddCTA.TextBox1.Text = .Item(0, .CurrentRow.Index).Value   
            AddCTA.TextBox2.Text = .Item(1, .CurrentRow.Index).Value
        End With
    Catch ex As Exception
    End Try
End Sub

Then in the DataGrid, I'll call the previous function with this code.

Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
    mostrar_datos()
    Me.Close()
End Sub

But nothing happens, the data is not passed to the parent form, nor is the child form closed. It does not send me any code execution error.

    
asked by Jonsin 15.03.2018 в 22:37
source

0 answers