http://www.vbforums.com/showthread.php?t=640015
If you're going to call the other button's click event sub directly, the least you could do is pass it the proper params instead of two Nothing's (in case sender is actually used in the event sub itself):
vb.net Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Button2_Click(Button2, EventArgs.Empty) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click MsgBox("Hello") End Sub
But ideally, you should never need to use a Button's PerformClick() method nor should you need to call an event's sub directly either, the code should be placed in it's own sub (accepting the needed params) and called from the multiple places that it's needed.
沒有留言:
張貼留言