如何将一行datagriview传递给另一个表单控件?
我有一个主窗体(MDI)打开一个带有按钮(搜索)和控件的窗体。这个按钮打开一个带有datagridview的窗体2.
我需要传递一行datagridview表格2到表格1控件。
我打开表单1:
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:
Dim f1 As New form1
f1.MdiParent= Me
f1.Show()
表格2
form 2
Dim f2 As New form2
f2.ShowDialog()
f2.Dispose()
我尝试了什么:
表格2:
私有子dgv1_CellContentDoubleClick(发件人为对象,e为DataGridViewCellEventArgs)处理dgv1.CellContentDoubleClick
If(e.RowIndex = -1)然后
返回
结束如果
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
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
阅读OriginalGriff关于在表格之间传递信息的文章
这是第一个之间传递信息两种形式,第1部分:父母与子女 [ ^ ] - 文章中有其他人的链接
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