【发布时间】:2017-05-25 06:19:55
【问题描述】:
我在 9 月份问过 a similar question(好吧,说实话,是一样的),但由于某种原因,这个问题的解决方案在我最近的事件中不起作用......
我的UltraGrid 现在用于输入订单中每一行的付款日期,并有一个CheckBox 列将其标记为已付款。为每个订单行付款后,订单进入下一阶段。
无论如何,当我创建的测试订单被标记为已交付并达到当前阶段(第 5 阶段 - 等待客户付款)时,我最初可以在每个订单行上编辑付款日期和 CheckBox 列。
但是,如果我将一个标记为已付款,而将另一个留空然后保存,则会出现以下问题。
我进入订单,将下一行标记为已付款。我可以输入付款日期,但不能将CheckBox 设置为True。事实上,单步执行后,单元格甚至没有输入EditMode,因为没有触发CellChange事件。
下面CellChange 中的代码应该允许在输入日期后将CheckBox 单元格设置为True - 但是,它没有进入编辑模式。
谁能明白为什么会这样?
Try
If e.Cell.Column.Key = "PaymentDate" Then
e.Cell.Row.Cells("Customer_Paid").Activation = Activation.AllowEdit
e.Cell.Row.Cells("Customer_Paid").IsInEditMode = True
End If
Catch ex As Exception
errorLog(ex)
End Try
Try
If e.Cell.Column.ToString = "Customer_Paid" Then
Dim customerPaid As Boolean = Boolean.Parse(e.Cell.Text)
If customerPaid = True Then
If IsDBNull(ugProducts.ActiveRow.Cells("PaymentDate").Value) Then
MsgBox("Please enter a payment date", MsgBoxStyle.OkOnly, "Invalid Date")
e.Cell.Row.Cells("Customer_Paid").Value = False
ugProducts.ActiveRow.Appearance.BackColor = Color.White
ugProducts.ActiveRow.Cells("PaymentDate").Value = DBNull.Value
Else
ugProducts.ActiveRow.Appearance.BackColor = Color.LightGreen
ugProducts.ActiveRow.Cells("Product_Price_Per").Appearance.BackColor = Color.LightGreen
End If
e.Cell.Row.Update()
Else
ugProducts.ActiveRow.Appearance.BackColor = Color.White
ugProducts.ActiveRow.Cells("Product_Price_Per").Appearance.BackColor = Color.LightGreen
ugProducts.ActiveRow.Cells("PaymentDate").Value = DBNull.Value
Exit Sub
End If
Else
End If
Catch ex As Exception
errorLog(ex)
End Try
没有错误,只是没有进入EditMode 状态。
上一个案例的解决方案是使用我这次添加的Boolean.Parse 行,但这次没有成功。
【问题讨论】:
-
您可以输入付款日期。这应该允许在复选框上进行编辑?但它没有检测到日期列被修改?
-
@Jaxedin 日期列将允许编辑,然后日期显示在单元格中,但是,当我单击
CheckBox时,它不会触发CellChange方法,所以 @987654337 @ 无法启用,即使代码执行了该行。 -
Ultragrid 中的复选框在焦点传递给另一个控件之前不会触发。如果是这种情况,您需要手动强制编辑模式
-
@Jaxedin 这就是我使用
Boolean.Parse(e.Cell.Text)的原因,它甚至会在它显示在屏幕上之前获得设置的值。无论如何,作为一个快速测试,我设置了付款日期,然后更改了ComboBox的值,将一些文本放入TextBox等,然后尝试了CheckBox,但还是不行跨度> -
使用 UltraGrid,您需要使用“UltraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode)”进入编辑模式。
标签: vb.net checkbox infragistics ultrawingrid editmode