On Aug 8, 2:14 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@gmx.atwrot e:
<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 applicationWind ow {
public event ToolClickEventH andler ToolClicked;
private UltraToolbarsMa nager _toolbarsManage r;
private ToolSecurityMan ager _toolSecurityMa nager;
//the following object as the event ToolClick
public UltraToolbarsMa nager ToolbarsManager {
get { return this._toolbarsM anager; }
}
//the following has the event CanClickTool
public ToolSecurityMan ager ToolSecurityMan ager {
get { return _toolSecurityMa nager; }
}
this._toolbarsM anager.ToolClic k += new
Infragistics.Wi n.UltraWinToolb ars.ToolClickEv entHandler(this .OnInternalTool Clicked);
//EXECUTES FIRST
private void OnInternalToolC licked(object sender,
Infragistics.Wi n.UltraWinToolb ars.ToolClickEv entArgs e) {
try
{
// enforce tool security by confirming that the tool can indeed be
clicked by asking the tool security manager first
if (!_toolSecurity Manager.CanClic k(e.Tool, new object[] {}))
return;
//other code processing if not false from
....
}
......
}
public bool CanClick(ToolBa se tool, params object[] args)
{
this.AssertVali dTool(tool);
ToolCancelEvent Args e = new ToolCancelEvent Args(false, tool,
args);
this.OnCanClick Tool(this, e);
return !e.Cancel;
}
}
Public Class AuthenticationS napIn {
InitializeCompo nent {
AddHandler _applicationWin dow.ToolSecurit yManager.CanCli ckTool,
AddressOf _applicationWin dowSnapIn_ToolS ecurityManager_ CanClickTool
}
Private Sub
_applicationWin dow_ToolSecurit yManager_CanCli ckTool(ByVal sender As
Object, ByVal e As ApplicationWind ow.ToolCancelEv entArgs)
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 {
InitializeCompo nent {
AddHandler _applicationWin dow.ToolbarsMan ager.ToolClick, AddressOf
_applicationWin dowSnapIn_Toolb arsManager_Tool Click
}
Private Sub _applicationWin dow_ToolbarsMan ager_ToolClick( )
....
End Sub
}