473,836 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cancelling event in event procedure

I want to cancel an event from its event procedure on some condition, I know
how to do this in VB6 i.e. by setting cancel=true. Please tell me how can I
do this in VB.net I don't know how to use the eventArgs in VB.net and neither
its help is available in MSDN.

I'm thank full to you in advance.
Nov 21 '05 #1
12 18440
Adil,

It depends on the event. However have a look at the eventarguments if it is
possible than it is normally

e.cancel = true or false.

I hope this helps,

Cor
Nov 21 '05 #2
Thanks for you reply but it didn't solve the problem, I actually want to
cancel the form's Load event. What I want to do is, To stop loading form on
some condition.

Please tell me if this is possible, or if there's any alternative solution
to this problem.

"Cor Ligthert [MVP]" wrote:
Adil,

It depends on the event. However have a look at the eventarguments if it is
possible than it is normally

e.cancel = true or false.

I hope this helps,

Cor

Nov 21 '05 #3
Adil,
Thanks for you reply but it didn't solve the problem, I actually want to
cancel the form's Load event. What I want to do is, To stop loading form
on
some condition.


In the forms load event you can simple place.
me.close

I hope this helps,

Cor
Nov 21 '05 #4
I've already tried me.close but it comes up with following error

"Additional information: Cannot call Close() while doing CreateHandle(). "

"Cor Ligthert [MVP]" wrote:
Adil,
Thanks for you reply but it didn't solve the problem, I actually want to
cancel the form's Load event. What I want to do is, To stop loading form
on
some condition.


In the forms load event you can simple place.
me.close

I hope this helps,

Cor

Nov 21 '05 #5
Adil,
I've already tried me.close but it comes up with following error

Your question is Cancellin an event in a event procedure.

I think that it is completly answered.

If you have another problem, than ask that direct, that saves others time.

Just my thought,

Cor
Nov 21 '05 #6
Cor,
As u suggested to correspond privately, tell me your email address. I've
sent mail at your address "no************ @planet.nl" but its bounced back.

As told, In load event I tried to close the form but it comes with error
"Additional information: Cannot call Close() while doing CreateHandle(). "

I've also tried to call me.Dispose() in constructor but the show method form
caller gives error because object destroyed before show method called.

I've also tried to do this in HandleCreated event but the same error

Please tell me if there's any other event before or after load event that I
can
use safely to cancel form loading, or if u have any other better idea to
tackle this situation please tell me that.
"Cor Ligthert [MVP]" wrote:
Adil,
I've already tried me.close but it comes up with following error

Your question is Cancellin an event in a event procedure.

I think that it is completly answered.

If you have another problem, than ask that direct, that saves others time.

Just my thought,

Cor

Nov 21 '05 #7
"Adil Akram" <Ad*******@disc ussions.microso ft.com> schrieb
Thanks for you reply but it didn't solve the problem, I actually
want to cancel the form's Load event. What I want to do is, To stop
loading form on some condition.

Please tell me if this is possible, or if there's any alternative
solution to this problem.

Don't show the form if you're not going to show it.
Armin
Nov 21 '05 #8
Adil,

The form class has in fact only one purpose: Showing a form.

Therefore if you don't want to show it use another class to decide if you
want to show it. By instance Armin, Herfried and others use a seperated
module main to start it from.

The best way to get some help in my opinion is to show *some* code by
instance as you have it now in your load form class. Than we maybe
understand what you want to do.

Or even better, explain as well what is the purpose to get that handle.

Cor
"Adil Akram" <Ad*******@disc ussions.microso ft.com> schreef in bericht
news:2E******** *************** ***********@mic rosoft.com...
Cor,
As u suggested to correspond privately, tell me your email address. I've
sent mail at your address "no************ @planet.nl" but its bounced back.

As told, In load event I tried to close the form but it comes with error
"Additional information: Cannot call Close() while doing CreateHandle(). "

I've also tried to call me.Dispose() in constructor but the show method
form
caller gives error because object destroyed before show method called.

I've also tried to do this in HandleCreated event but the same error

Please tell me if there's any other event before or after load event that
I
can
use safely to cancel form loading, or if u have any other better idea to
tackle this situation please tell me that.
"Cor Ligthert [MVP]" wrote:
Adil,
> I've already tried me.close but it comes up with following error
>

Your question is Cancellin an event in a event procedure.

I think that it is completly answered.

If you have another problem, than ask that direct, that saves others
time.

Just my thought,

Cor

Nov 21 '05 #9
Armin
Actually I want to prevent opening form if its already opened. I can do this
by writing code at caller but I want some generic code that works for all
forms to prevent a form opening twice.

"Armin Zingler" wrote:
"Adil Akram" <Ad*******@disc ussions.microso ft.com> schrieb
Thanks for you reply but it didn't solve the problem, I actually
want to cancel the form's Load event. What I want to do is, To stop
loading form on some condition.

Please tell me if this is possible, or if there's any alternative
solution to this problem.

Don't show the form if you're not going to show it.
Armin

Nov 21 '05 #10

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

Similar topics

0
3606
by: wang xiaoyu | last post by:
Hello,everyone. my program runs well in windows,i use tkSimpleDialog to receive some input,but when i copy my program into Linux RH8.0,entrys in my tkSimpleDialog derived Dialog have a vital problem:only one entry can receive key event,'tab' key to navigate between entrys is not valid too,when i use mouse to focus a entry(which can not navigate through 'tag' key),no matter what key i pressed the entry receive no reply.But in window they...
1
1891
by: Paul THompson | last post by:
I have been working for some time to 1) detect tab and shift tab events 2) control the focus on the basis of these events. I have found that I can do this, but continue to have nagging problems. One of the main problems at this point lies in cancelling the event. I have found that the TAB fires the onkeypress in NN, but not in IE. I can cancel the onkeypress fine in NN. The TAB fires the onkeydown in IE and can be cancelled in IE. ...
8
602
by: InvisibleDuncan | last post by:
I have a ListView that populates some fields whenever the user selects an item. However, if they change the data in the fields and then select a new item without saving, I want to display a message box that warns that their changes will be lost, and asks them to confirm whether to continue. Sounds simple Unfortunately, the ListView's SelectedIndexChanged event cannot be cancelled, and it's actually called for each change in the selection. So,...
4
1790
by: Newbie | last post by:
Is it possible to set up an event handler or something else so that when *any* link on the page is clicked it 'fires-up', executes some JS and then continues to process the link that was clicked? (Without having JS or 'onClick' added to each & every link?) I've looked everywhere but can't find out how, or if it's even possible via Javascript... Regards.
1
2918
by: GregM | last post by:
I have a read only datagrid that is designed to coordinate itself with textboxes. When the user clicks on a row in the datagrid, detailed data for that row is displayed for editing in the textboxes. The datagrid and textboxes are populated from the same underlying SQL Server table but using different strongly typed data adapters and datasets for display and editing. So I coordinate syncronization of the two sets of data using code. I use...
6
1767
by: Steve B. | last post by:
Is it good programming practice to call an event within an event? I'm I creating recursion somehow somewhere? Does an event (e.g. send, e) ever end? I'm sorry, I'm not sure I know what I mean, however, I do know what ever it is I should be aware of it. currentcell_event(..) { ..
2
1434
by: nford | last post by:
Is there a way to check if an object handles a certain type of event or if the object is hooked up to a certain event handler/call back function? For instance what would be the equivalent syntax in the following: Private x as Object Public Event TestEvent() Sub Y()
6
7732
by: MLH | last post by:
I have a form, frmUSPSReturnReceipts, with a control named NotExpectingGreenTickets. The control's Exit event procedure follows: Private Sub NotExpectingGreenTickets_Exit(Cancel As Integer) If IsNull(Me!NotExpectingGreenTickets) Then DoCmd.CancelEvent Exit Sub End If End Sub
9
4080
by: pvsundarram | last post by:
hey, i am trying to cancel the keydown event for certain keycodes( for eg:- enter key ).But the cancelling of this event is not happening in firefox. Is there any way to cancel the event in the iframe. CODE ===== <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en_US"
5
993
by: govolsbaby | last post by:
Not sure how to ask this so I'll try a couple ways. So I have a class with an event... Public Class myClass Public Event SomethingsGoingOn() Private Sub SomethingHappened(ByVal sender As Object, ByVal e As System.EventArgs) Handles Something.Happened 'code here changes some properties of myClass RaiseEvent SomethingsGoingOn()
0
9816
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
9668
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9371
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
7790
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
6978
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
5647
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
5823
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4448
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

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.