保存初始数据后,无法将UltraGrid Checkbox值设置为True [英] Cannot set UltraGrid Checkbox value to True after saving the initial data
问题描述
我的项目包含一个允许使用 UltraGrid
输入订单的表单。
My project contains a form which allows the entering of orders, using an UltraGrid
.
一个列是复选框
样式列,表示是否已下达订单。
One column is a checkbox
style column, to represent whether or not the order has been delivered.
当订单达到阶段时4-等待货物,用户可以将列值设置为 True
,这反过来会提示一个新窗口,以允许用户输入商品的数量和价值。交货。
如果订单未完全交付,则将复选框
设置回 False
,然后订单行变成黄色(例如,已订购5个门,但只有3个已交付= False
,但订单行为黄色)。
When the order reaches 'Stage 4 - Awaiting Goods Delivery', the user can set the column value to True
, which in turn prompts a new window, to allow the user to enter the volume and value of the delivery.
If the order hasn't been fully delivered, the checkbox
is set back to False
, and the order line turns yellow (Eg; 5 gates have been ordered, but only 3 delivered = False
, but a yellow order line).
保存订单,关闭订单并返回订单后,我试图将复选框
设置为 True
,以更新订单以添加其余交付(最后2个门已交付),但是一旦我将其设置为 True
,它立即再次变为 False
(在 CellChange
方法,它说单元格的值也是 False
)。
After saving the order, closing it and going back into it, I'm trying to set the Checkbox
to True
, to update the order to add on the rest of the delivery (the final 2 gates have been delivered), but as soon as I set it to True
, it instantly becomes False
again (When stepping through the following code in the CellChange
method, it says the cell value is False
too).
所以,为什么我只能更改该值一旦?保存后,为什么不能再次更改该值?
So, why can I only change the value once? After it's been saved, why can the value then not be changed again? Is it do with the fact that it's saved as False
in the database?
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
递归地触发,此后我不确定会发生什么,但是有更有效的方式编写此代码。
I was committing the value of the cell and then you are SETTING the value of the cell, which was causing CellChange
to fire again recursively, and after that I'm not sure what happens, but there was more effective ways of writing this code.
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
这篇关于保存初始数据后,无法将UltraGrid Checkbox值设置为True的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!