문제

I want to add a click event to a menu item which is created at runtime.

In Oxygene

var mi : MenuItem := new MenuItem();

In C# this would have been something like

mi.Click += EventHandler(...);

However Oxygene does not seem to use the += operator. Events seem to have been specially treated in Oxygene in a way which is different to C#. What happens when I want to use the original C# event handling so I can use the MenuItem?

도움이 되었습니까?

해결책

Click is an event. So

mi.Click += new EventHandler(@Click);

Works, or with a lambda:

mi.Click += (s, o) -> MessageBox.Show('Clicked the menu!');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top