2013-08-05 61 views
0

我正在做一些轉換編碼,使用找到的.net轉換庫@http://code.google.com/p/dot-net-transitions/。我正在嘗試添加一個事件來觸發已完成的轉換。在我的子,我有以下語句:爲什麼我的活動沒有開火?

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

的代碼是什麼'在AddHandler'線?它是在事件處理程序還是其他東西?你可以發佈第一個代碼清單的整個方法嗎? –

+0

我加了一點以上,它是在一個使用按鈕點擊。處理程序是在我的md5匹配條件之後添加的,理論上應該在轉換完成後觸發。 –

+0

'Addhandler'連接事件不會觸發事件。 – OneFineDay

回答

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 
+0

這幫了我很大的忙,謝謝! –