> > > In VB6 I have a screen the has a text box and a datagrid
>
[quoted text clipped - 20 lines]
> 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
Steve - 15 Oct 2007 15:44 GMT
> > > > In VB6 I have a screen the has a text box and a datagrid
>
[quoted text clipped - 37 lines]
>
> - 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
rowe_newsgroups - 15 Oct 2007 16:23 GMT
> > > > > In VB6 I have a screen the has a text box and a datagrid
>
[quoted text clipped - 47 lines]
>
> 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