Public Sub Initialize() WorkaroundTabIndexDefect() End Sub ''' <summary> ''' Works around the tab index defect. ''' </summary> Private Sub WorkaroundTabIndexDefect() For Each ctr As Control In Me.Controls SetKeyDownHandlers(ctr) Next End Sub ''' <summary> ''' Sets the key down handlers. ''' </summary> ''' <param name="ctr">The CTR.</param> Private Sub SetKeyDownHandlers(ByVal ctr As Control) Dim txtCtr As TextBox = TryCast(ctr, TextBox) If txtCtr IsNot Nothing Then txtCtr.AcceptsTab = True txtCtr.AcceptsReturn = True Dim evh As KeyEventHandler = New KeyEventHandler(AddressOf WorkaroundKeyDown) AddHandler txtCtr.KeyDown, evh Else ctr.TabStop = False End If If ctr.Controls.Count > 0 Then For Each subCtr As Control In ctr.Controls SetKeyDownHandlers(subCtr) Next End If End Sub ''' <summary> ''' Workarounds the key down. ''' </summary> ''' <param name="sender">The sender.</param> ''' <param name="e">The <see cref="System.Windows.Forms.KeyEventArgs" /> instance containing the event data.</param> Private Sub WorkaroundKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Try If Me.ActiveControl IsNot Nothing Then Select Case e.KeyCode Case Keys.Return Dim btnCtr As Windows.Forms.Button = TryCast(Me.ActiveControl, Windows.Forms.Button) If btnCtr IsNot Nothing Then btnCtr.PerformClick() End If Case Keys.Tab If e.Shift Then Me.SelectNextControl(CType(sender, Control), False, True, True, True) Else Me.SelectNextControl(CType(sender, Control), True, True, True, True) End If End Select End If Catch ex As Exception Trace.WriteLine(ex) End Try End Sub
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.