473,499 Members | 1,618 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 8883
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...@yahoo.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...@yahoo.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...@yahoo.comwrote:
On Oct 15, 9:36 am, Steve <eastforkfa...@yahoo.comwrote:


On Oct 15, 8:10 am, rowe_newsgroups <rowe_em...@yahoo.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...@yahoo.comwrote:
On Oct 15, 9:36 am, Steve <eastforkfa...@yahoo.comwrote:
On Oct 15, 8:10 am, rowe_newsgroups <rowe_em...@yahoo.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_Validating(ByVal sender As System.Object,
ByVal e As System.ComponentModel.CancelEventArgs) Handles
TextBox1.Validating
e.Cancel = String.IsNullOrEmpty(TextBox1.Text)

If e.Cancel Then RemoveHandler DataGridView1.MouseDown,
AddressOf DataGridView1_MouseDown
End Sub

Private Sub TextBox1_Validated(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBox1.Validated
AddHandler DataGridView1.MouseDown, AddressOf
DataGridView1_MouseDown
End Sub

Private Sub DataGridView1_MouseDown(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
DataGridView1.MouseDown
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
4189
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...
6
2836
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...
5
1564
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....
4
10261
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...
9
2454
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...
21
9112
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...
5
1808
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...
2
3288
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: ...
5
2288
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...
0
7132
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,...
0
7223
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...
1
6899
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
5475
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,...
1
4919
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...
0
4602
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...
0
3103
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...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
302
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...

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.