Ernst wrote:OK couldnt get your DeliveryAddress1EditableLookup_ButtonClicked Breakout going, as I had no access to the plugin, from there, so couldnt do your line
clsSearch search = this.manager.Search
A trick you can use is to inject whatever parameters you like into an event handler using a lambda which has access to all the variables in scope at the time of adding the handler.
So you could have passed the plugin as a parameter to the DeliveryAddress1EditableLookup.ButtonClicked event handler.
For example, in a FormPlugin class:
- Code: Select all
Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
If TypeOf JiwaForm Is JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm Then
Dim salesOrderForm As JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm = JiwaForm
AddHandler salesOrderForm.DeliveryAddress1EditableLookup.ButtonClicked, Sub(sender As Object, e As System.EventArgs) DeliveryAddress1EditableLookup_ButtonClicked(sender, e, Plugin)
End If
End Sub
Private Sub DeliveryAddress1EditableLookup_ButtonClicked(sender As Object, e As System.EventArgs, Plugin As JiwaApplication.Plugin.Plugin)
System.Windows.Forms.MessageBox.Show(String.Format("I'm in DeliveryAddress1EditableLookup_ButtonClicked and I know about {0}", Plugin.Name))
End Sub
All we're doing in the above is in the AddHandler instead of just passing the AddressOf the DeliveryAddress1EditableLookup_ButtonClicked like you would normally do, is instead provide a lambda method and that calls DeliveryAddress1EditableLookup_ButtonClicked. The lambda can be considered like a local method inside the current method - and it has access to all the variables in scope at that time.