【问题标题】:Add rows to a DataGridView in a different Form以不同的形式将行添加到 DataGridView
【发布时间】:2019-04-08 08:35:41
【问题描述】:

如何将 DataGridView 行传递给不同表单上的 DataGridView?

pos_receipt.PrintTable.Rows.Add(row.Cells("item_info").Value.ToString,
    row.Cells("Quantity").Value.ToString,
    row.Cells("Rate").Value.ToString,
    row.Cells("total").Value.ToString)

注意:
pos_receipt是我要传递行的DataGridView所在的Form名称。

PrintTable是一个数据表

【问题讨论】:

标签: vb.net winforms datagridview


【解决方案1】:

取决于,如果您想要将行传递到的表单已经以您所在的表单创建, 您唯一需要做的就是目标表单中的公共函数并从您的原始表单中调用它。 ej:

    dim DestForm as new FormName()
    DestForm.GetRows(RowOfMyGrid)

在 dest 形式中

    Public sub GetRows(Row as datagridviewRow)
        myDataGrid.rows.add(Row)
    end sub

如果反过来,并且您想将行从目的地传递到起点,则必须使用事件来完成

【讨论】:

    猜你喜欢
    • 2012-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-03
    • 2016-02-09
    • 1970-01-01
    • 2014-09-01
    相关资源
    最近更新 更多