2013年10月16日 星期三

循環切換 Control focus

這就類似智慧型手機上的鍵盤輸入運用
想不到要搞定 focus 還真是花費好多時間
最終只好採用變數才能處理
--















--
當按[循環 focus] 即可在上面標示 1,2,3,1,2,3 如此切換 Control  focus
--
code:

 Public Class Form1
    Private focus_index As Integer = 0

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Select Case focus_index
            Case 0
                Txt2.Focus()
            Case 1
                Button2.Focus()
            Case 2
                Txt1.Focus()
        End Select      
    End Sub

    Private Sub Txt1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Txt1.GotFocus
        focus_index = 0
    End Sub
    Private Sub Txt2_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Txt2.GotFocus
        focus_index = 1
    End Sub
    Private Sub Button2_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.GotFocus
        focus_index = 2
    End Sub
End Class

沒有留言:

張貼留言