为什么循环 datagridview 中的每一行不会显示 vb.net 中消息框中的所有值

问题描述 投票:0回答:1

如果我的代码有问题,它也应该出现在代码产品“B”的消息框中,请指导我

谢谢

Dim ResutlQty_Stock = GetStock.Qty_Stock - (detail.Qty - Getprevdetailqty.Qty)

                For Each row As DataGridViewRow In DataGridView2.Rows
                    If ResutlQty_Stock < 0 Then
                        MessageBox.Show("no available stock for Codeproduct " & CStr(row.Cells("CodeProduct").FormattedValue))
                        DataGridView2.DataSource = itrservice.GetLoadStocksoutdetailMaster()
Return

                    End If
                Next row

DATAGRIDVIEW 中的结果

vb.net for-loop foreach datagridview messagebox
1个回答
0
投票

您必须使用datagridview的值来计算结果数量

    Dim Getprevdetailqty As Integer = 0
    For Each row As DataGridViewRow In DataGridView2.Rows
        Dim ResutlQty_Stock as Integer = GetStock.Qty_Stock - row.Cells("Qty").Value - Getprevdetailqty
        If ResutlQty_Stock < 0 Then
            MessageBox.Show("no available stock for Codeproduct " & CStr(row.Cells("CodeProduct").FormattedValue))
            DataGridView2.DataSource = itrservice.GetLoadStocksoutdetailMaster()
            Return

        End If
        Getprevdetailqty = Integer.Parse(row.Cells("Qty").Value)
    Next row
© www.soinside.com 2019 - 2024. All rights reserved.