473,796 Members | 2,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5625
<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.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
}

Aug 8 '07 #3
<nc*****@gmail. comschrieb
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
}
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
3940
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 sending the print command via ExecWB for the first .xml document either the preview or the printer selection window occurs (depending on the passed parameter). This behaviour is ok.
11
18350
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 still gets entered. I've stripped the function down just to try to get it to work in Firefox. The alert does happen on the keydown event so it should be cancellable. function formatInput(e){
1
8347
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 but that's the gist of it.) I have everything set up, and it seems to work except that setting Cancel to true and returning from my c# method appears to do nothing. Word still closes. Am I doing something wrong? private void...
1
7344
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 each line of a file, processes it , and writes it. With the Cancel button, I'd like to cancel this method. Is this possible? Thanks.
2
2009
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 enevnts? Thanks, Boni
1
3937
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 the "cancel" link. Any help would be appreciated. -- Thanks in advance, sck10
1
2997
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> and assign an event by doing:
5
3347
by: Diego | last post by:
How do I capture a cancel event of Printer dialog box? Regards, Diego
2
3063
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 console.How can I do that? Please help ! Thanks,
7
4673
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 table). Once the page has loaded, the script clears the message and graphic. It works fine, however if you click the button on the browser to cancel the page load, the browser will render what it can of the table and the "Please Wait" message...
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10217
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9047
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.