cancel
Showing results for 
Search instead for 
Did you mean: 

SDK. C#. Individual Item events.

Former Member
0 Kudos
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.

Accepted Solutions (0)

Answers (3)

Answers (3)

edy_simon
Active Contributor

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

former_member185682
Active Contributor

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

Former Member
0 Kudos

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

former_member185682
Active Contributor
0 Kudos

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