|
-
Mar 7th, 2006, 07:20 PM
#1
Thread Starter
Lively Member
Re: CausesValidation=false not working?
tg: ok check this out!
VB Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.CausesValidation = False
End Sub
Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
If TextBox1.Text = "" Then
MsgBox("You must enter something")
e.Cancel = True
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("Button1Click - No Me.Close event")
'MsgBox "Button1Click - Yes Me.Close event"
'Me.Close
End Sub
End Class
this is just a simple 1 form, 1 button, 2 textbox form. Please test this program and you'll see some weird (might be working right, who am i to say) stuff.
Notice that if you enable the code in button1 click, namely Me.Close, then the validation event for textbox1 will fire. But if you leave it disabled then you can get the MsgBox("Button1Click - No Me.Close event") just fine, however try and go straight to the close form "x" and then the textbox1 validating event fires. So, it's like it's still sitting at the TextBox1 validating event, but it allows non event things to happen?
EDIT: I'm beginning to think that I might be trying to use the CausesValidation event for something it's not meant to do. I mean, it makes sense to me that it would work how I want it to; that way if the user enters information that I cannot accept I can allow them the ability to cancel out of the form. That being said, it seems like the msdn pages are refering to using CausesValidation to pop up some Help for the user.
Last edited by Essential; Mar 7th, 2006 at 07:25 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|