A
Al Santino
Hi,
It appears displaying a messagebox in a validating event will cancel the
subsequent event. In the program below, button 2's click event doesn't fire
if you open a dialog box in button 1's validating event. Am I doing
something wrong here?
Thanks
Al
Imports system
Imports system.windows.forms
' Create a form, add two buttons and event handlers.
' Click on Button 2 to receive Button 1 validating
' event but not button 2's click event. MessageBox
' appears to kill the click event.
Module ValidateTest
Sub Main()
Dim frm As New Form()
Dim btn As New Button
btn.Text = "One"
btn.Parent = frm
AddHandler btn.Validating, AddressOf BtnValidating
btn = New Button
btn.Left = btn.Width + 3
btn.Text = "Two"
btn.Parent = frm
AddHandler btn.Click, AddressOf BtnClick
Application.Run(frm)
End Sub
Private Sub BtnValidating(ByVal sender As Object,
ByVal e As System.ComponentModel.CancelEventArgs)
MessageBox.Show("BtnValidating event")
End Sub
Private Sub BtnClick(ByVal sender As Object, ByVal e As
System.EventArgs)
MessageBox.Show("BtnClick event")
End Sub
End Module
It appears displaying a messagebox in a validating event will cancel the
subsequent event. In the program below, button 2's click event doesn't fire
if you open a dialog box in button 1's validating event. Am I doing
something wrong here?
Thanks
Al
Imports system
Imports system.windows.forms
' Create a form, add two buttons and event handlers.
' Click on Button 2 to receive Button 1 validating
' event but not button 2's click event. MessageBox
' appears to kill the click event.
Module ValidateTest
Sub Main()
Dim frm As New Form()
Dim btn As New Button
btn.Text = "One"
btn.Parent = frm
AddHandler btn.Validating, AddressOf BtnValidating
btn = New Button
btn.Left = btn.Width + 3
btn.Text = "Two"
btn.Parent = frm
AddHandler btn.Click, AddressOf BtnClick
Application.Run(frm)
End Sub
Private Sub BtnValidating(ByVal sender As Object,
ByVal e As System.ComponentModel.CancelEventArgs)
MessageBox.Show("BtnValidating event")
End Sub
Private Sub BtnClick(ByVal sender As Object, ByVal e As
System.EventArgs)
MessageBox.Show("BtnClick event")
End Sub
End Module