我正在使用。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
但是,转换完成后事件未触发。为什么会这样?
答案 0 :(得分: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