Hi,
I've created an extension method that works just like I wanted. I've noticed that somehow the party
and property
parameters are 'copied' into the lambda expression. This way I do not need to maintain a custom list of editor/party/property associations.
However, I need to reset the ButtonEdit's ButtonClick event. Since this one is anonymous I cannot use the -= opertor either.
So, my question is - how do I rewrite this method so that the delegate can be removed? Or, which other approach can I use to handle a specific event handler with extra parameters (such as party
and property
)?
private static void SetupAddressButtonClickEvent(this ButtonEdit editor, Party party, string property)
{
editor.SetAddressDisplayText(party, property);
editor.ButtonClick += (sender, e) =>
{
party.ShowAddressLookupDialog(property);
editor.SetAddressDisplayText(party, property);
};
}
Thank you, Stefan