保存初始数据后无法将 UltraGrid 复选框值设置为 True

Cannot set UltraGrid Checkbox value to True after saving the initial data

我的项目包含一个允许输入订单的表单,使用 UltraGrid

一栏为checkbox样式栏,表示订单是否已发货

当订单到达'Stage 4 - Awaiting Goods Delivery'时,用户可以将列值设置为True,进而提示一个新的window,让用户输入交易量和交货的价值。 如果订单未完全交付,则 checkbox 设置回 False,订单行变为黄色(例如;已订购 5 个门,但仅交付 3 个 = False,而是一条黄色订单行)。

保存订单、关闭订单并返回订单后,我正在尝试将 Checkbox 设置为 True,以更新订单以添加剩余的交货(最后 2 个门已交付),但一旦我将其设置为 True,它立即再次变为 False(在 CellChange 方法中单步执行以下代码时,它说单元格值也是 False)。

那么,为什么我只能更改一次值?保存后为什么不能再改了呢?与数据库中保存为False有关吗?

Try
  If e.Cell.Column.ToString = "Goods_Delivered" Then
     e.Cell.Row.Update()

       If e.Cell.Value = True Then
           If IsDBNull(e.Cell.Row.Cells("Final_Delivery").Value) Then
              MsgBox("Please enter a delivery date", MsgBoxStyle.OkOnly, "Invalid Date")
                    e.Cell.Row.Cells("Goods_Delivered").Value = False
           Else
            Dim f As New dlgDelivery(e.Cell.Row, Me, e.Cell.Row.Cells("Final_Delivery").Value, con, orderNumber, e.Cell.Row.Cells("Product_Code").Value, exTotal)
                f.ShowDialog()
           End If

           e.Cell.Row.Update()

        cmdCheck_Click(sender, New EventArgs)
        cmdTotals_Click(sender, New EventArgs)

  ElseIf e.Cell.Value = False Then
      ugProducts.ActiveRow.Cells("Final_Delivery").Value = DBNull.Value
       productCode = ugProducts.ActiveRow.Cells("Product_Code").Value
       database.NotDelivered(orderNumber, productCode, con)
     Exit Sub
  Else
  End If

其中的错误是 e.Row.Update()

我提交了单元格的值,然后你设置了单元格的值,这导致 CellChange 再次递归触发,之后我不确定会发生什么,但是是编写此代码的更有效方法。

Try
  If e.Cell.Column.Key = "Goods_Delivered" Then
   Dim goodsDelivered As Boolean = Boolean.Parse(e.Cell.Text)
     If goodsDelivered = True Then
      If IsDBNull(e.Cell.Row.Cells("Final_Delivery").Value) Then
       MsgBox("Please enter a delivery date", MsgBoxStyle.OkOnly, "Invalid Date")
       Dim checkEditor As CheckEditor = e.Cell.EditorResolved
       checkEditor.Value = False
      Else
       Dim f As New dlgDelivery(e.Cell.Row, Me, e.Cell.Row.Cells("Final_Delivery").Value, con, orderNumber, e.Cell.Row.Cells("Product_Code").Value, exTotal)
       f.ShowDialog()
      End If
     ElseIf goodsDelivered = False Then
       ugProducts.ActiveRow.Cells("Final_Delivery").Value = DBNull.Value
                productCode = ugProducts.ActiveRow.Cells("Product_Code").Value
                database.NotDelivered(orderNumber, productCode, con)
             Exit Sub
         End If
      End If

Catch ex As Exception
   errorLog(ex)

 End Try