473,783 Members | 2,286 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cancel/Clear Event Queue


In VB6 I have a screen the has a text box and a datagrid

If I click the datagrid, the 1st event is to validate the textbox and
then the 2nd event is a datagrid mousedown event. If a get an error
message in the textbox validate it seems the mousedown event is never
executed.

In VB.Net it executes the textbox validation and then displays the
error, but still executes the mousedown event. It appears that I have
to explicitly cancel/clear the event queue in VB.Net if there is an
error.

How do I do that?

Oct 15 '07 #1
5 8899
On Oct 15, 7:56 am, Steve <eastforkfa...@ yahoo.comwrote:
In VB6 I have a screen the has a text box and a datagrid

If I click the datagrid, the 1st event is to validate the textbox and
then the 2nd event is a datagrid mousedown event. If a get an error
message in the textbox validate it seems the mousedown event is never
executed.

In VB.Net it executes the textbox validation and then displays the
error, but still executes the mousedown event. It appears that I have
to explicitly cancel/clear the event queue in VB.Net if there is an
error.

How do I do that?
Did you use e.Cancel = True in the Validating event handler?

Thanks,

Seth Rowe

Oct 15 '07 #2
On Oct 15, 8:10 am, rowe_newsgroups <rowe_em...@yah oo.comwrote:
On Oct 15, 7:56 am, Steve <eastforkfa...@ yahoo.comwrote:
In VB6 I have a screen the has a text box and a datagrid
If I click the datagrid, the 1st event is to validate the textbox and
then the 2nd event is a datagrid mousedown event. If a get an error
message in the textbox validate it seems the mousedown event is never
executed.
In VB.Net it executes the textbox validation and then displays the
error, but still executes the mousedown event. It appears that I have
to explicitly cancel/clear the event queue in VB.Net if there is an
error.
How do I do that?

Did you use e.Cancel = True in the Validating event handler?

Thanks,

Seth Rowe

Seth,

I already do that, but the mousedown for the datagrid (not the
textbox) still executes.

Oct 15 '07 #3
On Oct 15, 9:36 am, Steve <eastforkfa...@ yahoo.comwrote:
On Oct 15, 8:10 am, rowe_newsgroups <rowe_em...@yah oo.comwrote:
On Oct 15, 7:56 am, Steve <eastforkfa...@ yahoo.comwrote:
In VB6 I have a screen the has a text box and a datagrid
If I click the datagrid, the 1st event is to validate the textbox and
then the 2nd event is a datagrid mousedown event. If a get an error
message in the textbox validate it seems the mousedown event is never
executed.
In VB.Net it executes the textbox validation and then displays the
error, but still executes the mousedown event. It appears that I have
to explicitly cancel/clear the event queue in VB.Net if there is an
error.
How do I do that?
Did you use e.Cancel = True in the Validating event handler?
Thanks,
Seth Rowe

Seth,

I already do that, but the mousedown for the datagrid (not the
textbox) still executes.
Alright, I figured I'd have you check the basics before I spent too
much time looking into it (lazy me :-)).

Imo, the MouseDown event should fire, because after all you did press
the mouse down on the datagrid. The behavior of a failed validation is
by default to just prevent a focus change, and not to prevent any
other control from performing an action. If you need to run some code
conditionally based on whether or not the textbox's validation
succeeded, the easiest (imo) method would be to use a simple boolean
flag that is checked by the MouseDown event handler.

Thanks,

Seth Rowe

Oct 15 '07 #4
On Oct 15, 10:08 am, rowe_newsgroups <rowe_em...@yah oo.comwrote:
On Oct 15, 9:36 am, Steve <eastforkfa...@ yahoo.comwrote:


On Oct 15, 8:10 am, rowe_newsgroups <rowe_em...@yah oo.comwrote:
On Oct 15, 7:56 am, Steve <eastforkfa...@ yahoo.comwrote:
In VB6 I have a screen the has a text box and a datagrid
If I click the datagrid, the 1st event is to validate the textbox and
then the 2nd event is a datagrid mousedown event. If a get an error
message in the textbox validate it seems the mousedown event is never
executed.
In VB.Net it executes the textbox validation and then displays the
error, but still executes the mousedown event. It appears that I have
to explicitly cancel/clear the event queue in VB.Net if there is an
error.
How do I do that?
Did you use e.Cancel = True in the Validating event handler?
Thanks,
Seth Rowe
Seth,
I already do that, but the mousedown for the datagrid (not the
textbox) still executes.

Alright, I figured I'd have you check the basics before I spent too
much time looking into it (lazy me :-)).

Imo, the MouseDown event should fire, because after all you did press
the mouse down on the datagrid. The behavior of a failed validation is
by default to just prevent a focus change, and not to prevent any
other control from performing an action. If you need to run some code
conditionally based on whether or not the textbox's validation
succeeded, the easiest (imo) method would be to use a simple boolean
flag that is checked by the MouseDown event handler.

Thanks,

Seth Rowe- Hide quoted text -

- Show quoted text -
Seth,

I agree. Although, this code will be used in over 100 projects, and I
hate to drag around an extra variable for each. Can you think of
anything that would be a little more imaginative?
Thanks ,

Steve
Oct 15 '07 #5
On Oct 15, 10:44 am, Steve <eastforkfa...@ yahoo.comwrote:
On Oct 15, 10:08 am, rowe_newsgroups <rowe_em...@yah oo.comwrote:
On Oct 15, 9:36 am, Steve <eastforkfa...@ yahoo.comwrote:
On Oct 15, 8:10 am, rowe_newsgroups <rowe_em...@yah oo.comwrote:
On Oct 15, 7:56 am, Steve <eastforkfa...@ yahoo.comwrote:
In VB6 I have a screen the has a text box and a datagrid
If I click the datagrid, the 1st event is to validate the textbox and
then the 2nd event is a datagrid mousedown event. If a get an error
message in the textbox validate it seems the mousedown event is never
executed.
In VB.Net it executes the textbox validation and then displays the
error, but still executes the mousedown event. It appears that I have
to explicitly cancel/clear the event queue in VB.Net if there is an
error.
How do I do that?
Did you use e.Cancel = True in the Validating event handler?
Thanks,
Seth Rowe
Seth,
I already do that, but the mousedown for the datagrid (not the
textbox) still executes.
Alright, I figured I'd have you check the basics before I spent too
much time looking into it (lazy me :-)).
Imo, the MouseDown event should fire, because after all you did press
the mouse down on the datagrid. The behavior of a failed validation is
by default to just prevent a focus change, and not to prevent any
other control from performing an action. If you need to run some code
conditionally based on whether or not the textbox's validation
succeeded, the easiest (imo) method would be to use a simple boolean
flag that is checked by the MouseDown event handler.
Thanks,
Seth Rowe- Hide quoted text -
- Show quoted text -

Seth,

I agree. Although, this code will be used in over 100 projects, and I
hate to drag around an extra variable for each. Can you think of
anything that would be a little more imaginative?

Thanks ,

Steve
Well, you could use Add/Remove Handler to dynamically control whether
the mousedown event is processed by your event handler.

Something like:

///////////////
Public Class Form1

Private Sub TextBox1_Valida ting(ByVal sender As System.Object,
ByVal e As System.Componen tModel.CancelEv entArgs) Handles
TextBox1.Valida ting
e.Cancel = String.IsNullOr Empty(TextBox1. Text)

If e.Cancel Then RemoveHandler DataGridView1.M ouseDown,
AddressOf DataGridView1_M ouseDown
End Sub

Private Sub TextBox1_Valida ted(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles TextBox1.Valida ted
AddHandler DataGridView1.M ouseDown, AddressOf
DataGridView1_M ouseDown
End Sub

Private Sub DataGridView1_M ouseDown(ByVal sender As System.Object,
ByVal e As System.Windows. Forms.MouseEven tArgs) Handles
DataGridView1.M ouseDown
MessageBox.Show ("MouseDown" )
End Sub

End Class
///////////////

Thanks,

Seth Rowe

Oct 15 '07 #6

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

Similar topics

8
4207
by: Graeme Matthew | last post by:
Hi all I just cannot seem to find any documentation that shows an example of using the factory method Event() in threads. I have a thread pool and if there are no jobs in a Queue I want them to wait for something to be inserted. When a job is inserted I want to send an Event, the first thread that picks it up runs with the job the rest wait for another insert Event. I have been looking at some C, c++ implementations and some use a...
6
2883
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a TimerState object similar to the example in the System.Threading.Timer documentation. The method which handles the timer events, among other things, periodically calls a method in this TimerState object which raises an event to the startup form,...
5
1573
by: | last post by:
I have a thread which is displaying a msgbox. I need to programmatically cancel the message box if the user does click on OK. I tried to abort the thread T1.abort() , but am getting an exception. Is there a way to do this?
4
10296
by: Russell Warren | last post by:
I'm guessing no, since it skips down through any Lock semantics, but I'm wondering what the best way to clear a Queue is then. Esentially I want to do a "get all" and ignore what pops out, but I don't want to loop through a .get until empty because that could potentially end up racing another thread that is more-or-less blindly filling it asynchronously. Worst case I think I can just borrow the locking logic from Queue.get and clear...
9
2471
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the post event will always execuate after the system is completed... - I want to wrap this functionality in a framework, so I could possibly have 3 or 4 levels of inherited objects that need to have these pre / post events executed before and after the...
21
9220
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on the cancel button, the textbox.validating is being called. I don't want it to be since they are exiting the screen the validation doesn't have to be done. How can I do that.
5
1826
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2.0. I have a form with crystal Viewer that I call as showdialog. I want to give the user an option to cancel out of it is it's taking too long to process. Is there a way to do this? How can I pop up another dialog box or message in this dialog form for user to click on a Cancel button if it's taking to long to display the report? -- Thanks.
2
3311
by: Steve | last post by:
I have segmentation fault when calling resize on an stl vector. I'm unsure if I'm doing something horribly wrong or if the stl is being dumb. The code breaks down like this: ------------------------------------- class Device { public: Device() { m_isBusy = false;
5
2308
by: nt5515 | last post by:
im trying to write a program that store a binary tree of possible events in an array. i need to be able to sort the the Events in the array based on the previous event that caused it by the time which they will occur. After the specific time has passed the event will be removed and all other events will be bumped up, all the while new events will be added to the end and sorted by their time. Please Help heres wot i've got so far, i've got...
0
9643
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
9480
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
10147
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...
1
10083
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9946
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
8968
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
7494
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.