473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I cancel an event

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?

Aug 8 '07 #1
4 5608
<nc*****@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/>
Aug 8 '07 #2
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
}

Aug 8 '07 #3
<nc*****@gmail.comschrieb
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
}
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

Aug 8 '07 #4
Check out Remove Handler and Add Handler to temporairly prevent an event from
firing.
--
Dennis in Houston
"nc*****@gmail.com" wrote:
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?

Aug 9 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Hautzendorfer | last post by:
Hello, I'm currently working on some printing stuff: I have to print out several .xml files using a stylesheet. Therefor I choose the Internetexplorer PlugIn via SHDocVW. My problem: After...
11
by: ryanmhuc | last post by:
I have a function which needs to cancel the input into a text field on a form. I cancel the event in IE fine and the text does not get entered. But for firefox (1.0) I cancel the event and the text...
1
by: AP | last post by:
Hi, I'm trying to use c# to pop up a dialog box when a user attempts to close word to prompt them if they want to exit or cancel (obviously other stuff needs to happen based on their selection...
1
by: VM | last post by:
How can I cancel all running processes in my application when I click on the Cancel button? When the Run button's clicked, it creates an instance of a specified class and runs a method that reads...
2
by: Boni | last post by:
Dear all, I would like to cancel the keydown event after I handled it in my control. But the handled=true of the event don't do the job. Is the some stronger method to clear key buffer and remove...
1
by: sck10 | last post by:
Hello, When using a FormView, DetailsView or GridView, how do you capture the cancel event when you are in the insert/update mode. I have a formview that I need to hide if the person clicks on...
1
by: dave | last post by:
What I am attempting to do is cancel an event in IE inside of my event handler, but the handler keeps getting called: for example if I do <div id="foo"> <div id="test">test text</div> </div>...
5
by: Diego | last post by:
How do I capture a cancel event of Printer dialog box? Regards, Diego
2
by: =?Utf-8?B?TmVldGE=?= | last post by:
Hi, I creating a console application. In that I want to catch the cancel event of the console application .Please guide me in this.I figured out that I will have to attach event to the...
7
by: John Gault | last post by:
I experimented with a snippet of JavaScript that will display a "Please Wait" message and graphic while the results of a cgi script is running (the script grabs a bunch of data and formats it in a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.