Vb.Net将Datagrid视图值传递给另一个Open Form

时间:2017-07-13 13:32:33

标签: vb.net datagridview

我有两种形式。当用户单击“费用表单”上的按钮时,将打开form2,其中包含一个包含从数据库获取的记录的datagridview。我希望所选单元格的详细信息显示在费用表单中的不同控件上双击一行时。我已尝试使用下面的代码,但它不起作用,因为当双击单元格时,form2隐藏了但是datagridview内容以费用形式传递给它们各自的控件。结果协助。

        If e.RowIndex >= 0 Then
            Dim dgv As DataGridView
            dgv = dgvbudget

            Expenses.txtid.Text = dgv.CurrentRow.Cells(0).Value.ToString
            Expenses.cboseasons.Text = dgv.CurrentRow.Cells(2).Value.ToString
            Expenses.dtpexpensedate.Value = CDate(dgv.CurrentRow.Cells(3).Value)
            Expenses.cboexpenseacc.Text = dgv.CurrentRow.Cells(5).Value
            Expenses.txtamount.Text = CDbl(dgv.CurrentRow.Cells(6).Value)
            Me.Hide()

        End If
    Catch ex As Exception
        MessageBox.Show(ex.Message, "CMS", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try
End Sub

0 个答案:

没有答案
相关问题