Question

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?

Était-ce utile?

La solution

Click is an event. So

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

Works, or with a lambda:

mi.Click += (s, o) -> MessageBox.Show('Clicked the menu!');
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top