0

I asked a similar question (Well, indentical, in honesty) back in September, but the solution to that issue is, for some reason, not working in my latest incident...

My UltraGrid is being used now to enter the date of payment for each line in the order, and has a CheckBox column to mark it as paid. When each order line is paid for, the order progresses to the next stage.

Anyway, when the test order that I created is marked as delivered, and reaches the current stage (Stage 5 - Awaiting Customer Payment), I am initially able to edit the payment date and CheckBox column on each order line.

However, if I mark one as paid, and leave the other one blank and then save it, the following issue arises.

I go into the order to mark the next line as paid for. I am able to enter a date of payment, but not set the CheckBox to True. In fact, after stepping through it, the cell doesn't even enter EditMode, as the CellChange event is not triggered.

The code in CellChange below is supposed allow the CheckBox cell to be set to True once a date has been entered - However, it isn't entering Edit Mode.

Can anybody see why this would be?

 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

There are no errors, it just doesn't enter the EditMode state.

The solution with the previous case was to use the Boolean.Parse line that I've added this time around, yet it is unsuccessful this time.

Community
  • 1
  • 1
David
  • 2,298
  • 6
  • 22
  • 56
  • You can enter the date of payment. This should allow edit on the Checkbox? but it is not detecting that the date column was modified? – Esselans Jan 10 '17 at 17:11
  • @Jaxedin The date column will allow editing, and the date then displays in the cell, however, when I click the `CheckBox`, it doesn't fire the `CellChange` method, so `EditMode` can't have been enabled, even though the code executed that line. – David Jan 10 '17 at 17:12
  • Checkbox in Ultragrid won't fire until focus is passed to another control. If that's your case, you need to manually force the Edit mode – Esselans Jan 10 '17 at 17:14
  • @Jaxedin That's why I'm using `Boolean.Parse(e.Cell.Text)`, that will get the value it's been set to even before it's displayed on screen. Anyway, just as a quick test, I set the payment date, then changed the value of a `ComboBox`, put some text into a `TextBox` etc, then tried the `CheckBox`, and still it didn't work – David Jan 10 '17 at 17:19
  • With UltraGrid you need to use ´ UltraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode)´ to enter edit mode. – Esselans Jan 10 '17 at 17:21
  • @Jaxedin Hmm, still nothing.. Even after using other controls, it still doesn't work... I'm starting to think that elsewhere in the code it has been overridden, but if I'm setting Edit Mode in the previous action, why should that matter – David Jan 10 '17 at 17:26

1 Answers1

0

Not the fix to the issue as such, but a way I got around it...

I changed the PaymentDate entry from allowing EditMode, to just setting the CheckBox to True.

The end user may not want it done this way, however, so question may still be unanswered, but just for now, this works.

If e.Cell.Column.Key = "PaymentDate" Then
   e.Cell.Row.Cells("Customer_Paid").Activation = Activation.AllowEdit
   e.Cell.Row.Cells("Customer_Paid").Value = True
End If
David
  • 2,298
  • 6
  • 22
  • 56