Skip to Content

BubbleEvent in Validation Handler has no effect

Hello Experts,

I am trying to validate a value the user enters in a cell of a grid. If I add the eventHandler via Grid0.Columns.Item("ColId").ValidateBefore += ValidationHandler, everything works fine. But for some reason the eventHandler gets lost over time, although the form is still active. So I tried to add a EventHandler to the SBO_Application.ItemEvent, and remove it when the form gets closed. But now the BubbleEvent = false has no effect on the Grid behaviour (a invalid value is entered, but the user can still change cell focus).

Thanks in advance and best regards!

 private void SBO_Application_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
            BubbleEvent = true;
                &&  pVal.ItemUID == Grid0.Item.UniqueID
                &&  pVal.FormUID == UIAPIRawForm.UniqueID
                &&  pVal.Row >= 0
                &&  pVal.ColUID == COLID_VALUE
                &&  pVal.EventType == SAPbouiCOM.BoEventTypes.et_VALIDATE
                &&  pVal.ItemChanged
                SetParameter(pVal.Row, out BubbleEvent);
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Apr 12, 2018 at 12:35 AM


    Grid0.Columns.Item("ColId").ValidateBefore += ValidationHandler

    This will work as long as the Grid(0).Columns.Item("ColId") lives in the memory.
    Once the GC collected this object, this reference to the handler will become invalid.
    Also note that this can lead to a memory leak situation.

    To properly handle this event you have a few option:

    1. Add the handler to the Grid0 instead of the specific column.
    2. If you want to handle the specific column, declare your column as a variable, and add the handler to this variable.

    Note that you also need to make sure that the Grid0 or the Column variable lives through out your form's life, so that GC does not collect it.


    Add comment
    10|10000 characters needed characters exceeded