How do I cancel an event

  • Thread starter Thread starter ncarnal
  • Start date Start date
N

ncarnal

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?

Any help would be appreciated?
 
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?
 
Could you post some code and/or give some more details?

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.ToolClickEventHandler(this.OnInternalToolClicked);


//EXECUTES FIRST
private void OnInternalToolClicked(object sender,
Infragistics.Win.UltraWinToolbars.ToolClickEventArgs 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.CanClickTool,
AddressOf _applicationWindowSnapIn_ToolSecurityManager_CanClickTool
}

Private Sub
_applicationWindow_ToolSecurityManager_CanClickTool(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
}
 
Public Class AuthenticationSnapIn {
InitializeComponent {
AddHandler _applicationWindow.ToolSecurityManager.CanClickTool,
AddressOf _applicationWindowSnapIn_ToolSecurityManager_CanClickTool
}

Private Sub
_applicationWindow_ToolSecurityManager_CanClickTool(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


}

What's that??? You're not mixing different languages, aren't you?
This doesn't look like VB.Net code at all - but maybe I missed something...
;-)


Armin
 
Back
Top