P
Pascal
Hi,
I have a very simple form which is opened with ShowDialog. It has a
TextBox that should not accept blank values and a Close button. The
CausesValidation property of the Close button is set to False; textbox
validation is fired using the Validate method (I know this seems a bit
silly, but it would take me too long to explain why I need to do it
like this).
When the textbox is empty and I click the Close button the first time,
the Close event is cancelled, which is fine. However, when I click
the Close button again, nothing happens : the Click event is not event
raised. Only when I click the Close button again, the Click event is
raised and the Close event is cancelled again. Why do I need to click
twice???
I use the following 3 procedures :
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnClose.Click
Me.Close()
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Not Me.Validate Then e.Cancel = True
End Sub
Private Sub TextBox1_Validating(ByVal sender As System.Object,
ByVal e As System.ComponentModel.CancelEventArgs) Handles
TextBox1.Validating
If Me.TextBox1.Text = "" Then
MsgBox("Empty not allowed...")
e.Cancel = True
End If
End Sub
Any help would be greately appreciated!
Pascal
I have a very simple form which is opened with ShowDialog. It has a
TextBox that should not accept blank values and a Close button. The
CausesValidation property of the Close button is set to False; textbox
validation is fired using the Validate method (I know this seems a bit
silly, but it would take me too long to explain why I need to do it
like this).
When the textbox is empty and I click the Close button the first time,
the Close event is cancelled, which is fine. However, when I click
the Close button again, nothing happens : the Click event is not event
raised. Only when I click the Close button again, the Click event is
raised and the Close event is cancelled again. Why do I need to click
twice???
I use the following 3 procedures :
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnClose.Click
Me.Close()
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Not Me.Validate Then e.Cancel = True
End Sub
Private Sub TextBox1_Validating(ByVal sender As System.Object,
ByVal e As System.ComponentModel.CancelEventArgs) Handles
TextBox1.Validating
If Me.TextBox1.Text = "" Then
MsgBox("Empty not allowed...")
e.Cancel = True
End If
End Sub
Any help would be greately appreciated!
Pascal