Thanks, Stuart - for reporting this and especially thanks for being generous and sharing a workaround!
One issue with the plugin you have provided is multiple instance interference when using a private variable in the plugin classes - as discussed in this
post.
It's only a potential issue where you have the same form (in this case the Price Schemes form) open multiple times - and I know you are probably aware of the issue, and I, myself, are guilty of using the same flawed strategy.
I know it's highly unlikely in this case for it to pose a problem, but It's a good habit to avoid using private variables.
I'm not so much pointing this out for your benefit, as I know you already know all this - but for those following along or stumbling across this post in the future and adapting the code for their own purposes.In this case, you stash away a reference to the form in a private variable, pform within the SetupBeforeHandlers method - so you can access that within the UltraToolbarsManager1.ToolClick handler of the form.
You could instead of gotten back to the form instance within the handler using the DockWithinContainer property - which you yourself demonstrated
here.
An alternative to this, which is useful for other handlers where you don't have a useful property like the DockWithinContainer property to get a reference back to the form (or anything else) is to inject properties into the handler using a delegate...
- Code: Select all
public void SetupBeforeHandlers(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
JiwaFinancials.Jiwa.JiwaPriceSchemesUI.frmPriceScheme pform = (JiwaFinancials.Jiwa.JiwaPriceSchemesUI.frmPriceScheme) JiwaForm;
pform.UltraToolbarsManager1.ToolClick += delegate(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { UltraToolbarsManager_ToolClick(sender, e, pform); };
}
...
public virtual void UltraToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e, JiwaFinancials.Jiwa.JiwaPriceSchemesUI.frmPriceScheme pform)
{
// in here we have access to the pform parameter, which was injected at the time of adding the handler - no need for a private variable and avoiding interference when the same form is open multiple times.
}
Again, I know you already are
familiar with the above technique - just pointing this out for the benefit of others