0

我正在使用 @ http://code.google.com/p/dot-net-transitions/找到的 .net 过渡库进行一些过渡编码。我正在尝试添加一个事件以在转换完成时触发。在我的子中,我有以下陈述:

Private Sub btnLogin_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click

If md5Password = rtnPassHash Then

                AddHandler Me.TransitionCompletedEvent, AddressOf theHandlerFunction

                Dim tr_empID = New Transition(New TransitionType_Linear(500))
                tr_empid.add(txtEmployeeID, "BackColor", Color.LightGreen)

                Dim tr_passw = New Transition(New TransitionType_Linear(500))
                tr_passw.add(txtPassword, "BackColor", Color.LightGreen)

                tr_empID.run()
                tr_passw.run()
                AddHandler Me.TransitionCompletedEvent, AddressOf theHandlerFunction

                Dim tr_empID = New Transition(New TransitionType_Linear(500))
                tr_empid.add(txtEmployeeID, "BackColor", Color.LightGreen)

                Dim tr_passw = New Transition(New TransitionType_Linear(500))
                tr_passw.add(txtPassword, "BackColor", Color.LightGreen)

                tr_empID.run()
                tr_passw.run()

end if

end sub

在那个子之外,我有:

Public Event TransitionCompletedEvent As EventHandler(Of Transition.Args)

Private Sub theHandlerFunction(ByVal sender As Object, ByVal args As Transition.Args) Handles Me.TransitionCompletedEvent
    MsgBox("Event Fired")

End Sub

但是,转换完成后事件不会触发。为什么会这样?

4

1 回答 1

1

基本设计:

Public Class Transition
  Public Event TransitionCompleted(args As Transition.Args)
  Public Sub SomeSub()
    RaiseEvent TransitionCompleted(New Transition.Args With {set some properties})
  End Sub
  ...
End Class

Public Class Form1
 Private transition1 As New Transition
 Private Sub Login_Click(...) ...
  ...
  Addhandler transition1.TransitionCompleted, AddressOf TransitionCompleted
 End Sub

 Private Sub TransitionCompleted(args As Transition.Args) ' no handles clause
   MessageBox.Show("event fired")
 End Sub
End Class
于 2013-08-05T19:41:24.693 回答