Click here to Skip to main content
15,891,942 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Main Form(MDI)that Opens a form with a button(search) and controls.This button opens a Form 2 with a datagridview.
I need to pass a row of datagridview that is in Form 2 to Form 1 controls.
I open my form 1:
VB
Dim f1 As New form1
f1.MdiParent= Me
f1.Show()

form 2
VB
Dim f2 As New form2
f2.ShowDialog()
f2.Dispose()


What I have tried:

Form 2:
Private Sub dgv1_CellContentDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgv1.CellContentDoubleClick
If (e.RowIndex = -1) Then
Return
End If
Dim dr As DataGridViewRow = dgv1.SelectedRows(0)

Me.Hide()
form1.Show()

form1.txtID.Text = dr.Cells(0).Value.ToString()
form1.txtNo.Text = dr.Cells(1).Value.ToString()
End Sub
Posted
Updated 4-Mar-16 5:18am
v4

1 solution

Have a read of OriginalGriff's articles on passing information between forms

This is the first oneTransferring information between two forms, Part 1: Parent to Child[^] - there are links to the others within the article
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900