Skip to Content
avatar image
Former Member

SDK. C#. Individual Item events.

public void CreateButton()
{
    Item button = ...
    // Create button
    ...
    ...
    ...
    ( button.Specific as Button ).ClickAfter += OnClick;
}
			
public void OnClick( object sboObject, SBOItemEventArg pVal )
{	
    // MessageBox
}

Hello. I have a question about individual item events. It is impossible to cause the event. The above code does not work. How can I rise this event (without inspection if(form && button && event_type) ). Thanks.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Jan 11, 2017 at 04:24 PM

    Hi Roman,

    Your code should be work. I have tested and works fine.

    Check if your code doesn't have some EventFilter config.

    My SAP B1 version is 9.1 PL 12.

    Hope it helps.

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 12, 2017 at 12:42 AM

    Hi Roman,

    This boils back to the scope of your variable.
    You did not declare a variable for the Button. The reference for your button item will be in local of this procedure.
    Once it goes out of scope and the GC collected it, the event will not trigger anymore.

    Solution is to declare an SAPbouiCOM.Button object in a place where this button object will live as long as you need it.
    Usually it is a variable in your class to handle this form.

    Regards
    Edy

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 13, 2017 at 07:26 AM

    Thanks, Diego. You was right - it's bad EventFilter in program. Now it works.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Roman,

      Great.

      I would to suggest you to use the approach provided by Edy on answer above to avoid future problems and don't forget to click on accept button below of my answer.

      Kind Regards,

      Diego Lother