0

I have a while loop, that I want my program to run through while a user has a form active. right now I have tried both,

While frmLineProduct.ActiveForm.Focus = True
While (frmLineProduct.ActiveForm.Equals(True))

But neither of these work. I am going to keep reading on this but if someone has already knows how to do this, I would appreciate the lesson.

4

2 に答える 2

1

次に、ステータスを制御するためにいくつかのイベントを実装できます。

Public Property HasFocus As Boolean = True 'global flag

Private Sub Form_Deactivated(sender As Object, e As System.EventArgs) _
    Handles Me.Deactivated
    _hasFocus = False
End Sub

Private Sub Form_Activated(sender As Object, e As System.EventArgs) _
    Handles Me.Activated
    _hasFocus = True
End Sub

次に、コードで:

While Form.Hasfocus
    Application.DoEvents 'a work-around for receiving events while in a while
于 2012-11-09T16:27:52.637 に答える
0

答えは、私が以前に聞いたことのない方法であることになりましたが、他の投稿の誰かが私をそれに導きました。

Control.Invokeメソッド(Delegate、Object())

興味のある人はここで答えを見つけることができます

于 2012-12-10T12:18:05.110 に答える