如何将一行datagriview传递给另一个表单控件? [英] How to pass a row of a datagriview to another form controls ?

查看:71
本文介绍了如何将一行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


这篇关于如何将一行datagriview传递给另一个表单控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆