On Aug 8, 2:14 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@gmx.atwrote:
<ncar...@gmail.comschrieb:
I have two events on a control that are wired up to other controls.
Both events fire upon clicking a menu item, how do I cancel the second
event if I return e.Cancel = True from the first event?
Could you post some code and/or give some more details?
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
The following is an example for the issue I am having:
public class applicationWindow {
public event ToolClickEventHandler ToolClicked;
private UltraToolbarsManager _toolbarsManager;
private ToolSecurityManager _toolSecurityManager;
//the following object as the event ToolClick
public UltraToolbarsManager ToolbarsManager {
get { return this._toolbarsManager; }
}
//the following has the event CanClickTool
public ToolSecurityManager ToolSecurityManager {
get { return _toolSecurityManager; }
}
this._toolbarsManager.ToolClick += new
Infragistics.Win.UltraWinToolbars.ToolClickEventHa ndler(this.OnInternalToolClicked);
//EXECUTES FIRST
private void OnInternalToolClicked(object sender,
Infragistics.Win.UltraWinToolbars.ToolClickEventAr gs e) {
try
{
// enforce tool security by confirming that the tool can indeed be
clicked by asking the tool security manager first
if (!_toolSecurityManager.CanClick(e.Tool, new object[] {}))
return;
//other code processing if not false from
....
}
......
}
public bool CanClick(ToolBase tool, params object[] args)
{
this.AssertValidTool(tool);
ToolCancelEventArgs e = new ToolCancelEventArgs(false, tool,
args);
this.OnCanClickTool(this, e);
return !e.Cancel;
}
}
Public Class AuthenticationSnapIn {
InitializeComponent {
AddHandler _applicationWindow.ToolSecurityManager.CanClickToo l,
AddressOf _applicationWindowSnapIn_ToolSecurityManager_CanCl ickTool
}
Private Sub
_applicationWindow_ToolSecurityManager_CanClickToo l(ByVal sender As
Object, ByVal e As ApplicationWindow.ToolCancelEventArgs)
If Not ValidUser() Then
e.Cancel = True
'THIS IS WHERE I WOULD LIKE TO CANCEL THE HANDLER FOR
ProviderSnapIn (below)
End If
End Sub
}
Public Class ProviderSnapIn {
InitializeComponent {
AddHandler _applicationWindow.ToolbarsManager.ToolClick, AddressOf
_applicationWindowSnapIn_ToolbarsManager_ToolClick
}
Private Sub _applicationWindow_ToolbarsManager_ToolClick()
....
End Sub
}