Skip to Content
0

SDK. C#. Individual Item events.

Jan 11, 2017 at 03:44 PM

184

avatar image
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.

sdk | c# | button | events | form | item
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

DIEGO LOTHER Jan 11, 2017 at 04:24 PM
1

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

Share
10 |10000 characters needed characters left characters exceeded
Edy Simon Jan 12, 2017 at 12:42 AM
1

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

Share
10 |10000 characters needed characters left characters exceeded
Roman Sav Jan 13, 2017 at 07:26 AM
0

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

Show 1 Share
10 |10000 characters needed characters left 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

0