That worked. I''ve gone a slightly different way - I''m hooking the CellRenderer controls in my parent form like this :
private void gridParty_CurrentCellControlGotFocus(object sender, System.Windows.Forms.ControlEventArgs e)
{
if (e.Control is GridMaskedEditBox)
{
if (e.Control.ContextMenu != null)
e.Control.ContextMenu = new ContextMenu();
if (this.popupMenusManager.GetXPContextMenu
(e.Control) != this.popupMenuParty)
this.popupMenusManager.SetXPContextMenu
(e.Control, this.popupMenuParty);
}
}
private void gridParty_CurrentCellControlLostFocus(object sender, System.Windows.Forms.ControlEventArgs e)
{
if (e.Control is GridMaskedEditBox)
{
if (this.popupMenusManager.GetXPContextMenu
(e.Control) == this.popupMenuParty)
this.popupMenusManager.SetXPContextMenu
(e.Control, null);
e.Control.ContextMenu = null;
}
}
This works exactly as I wanted it to, my XPMenu is invoked from within the MaskEdit cell control.
Of course, there''s a catch. Now my Dispose() blows up with the attached stack trace if I enter a MaskEdit cell. I''ve verified in the Dispose that the LostFocus code is being called prior to anything being disposed (did a MoveTo(-1,-1)). I even watched the PopupMenuManager decrement it''s count of menus to verify that reference was removed.
stacktrace_9056.zip