1

TextChange イベントでテキスト ボックスのテキストを変更したいのですが、TextChanged イベントがトリガーされ続けます。

RemoveHandler を試してみましたが、うまくいきません。ただし、_TextChanged Sub の外で使用すると機能します。

Private Sub txtLegalNameLast_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtLegalNameLast.TextChanged
    RemoveHandler txtLegalNameLast.TextChanged, AddressOf txtLegalNameLast_TextChanged
    txtLegalNameLast.Text = "Mr. " + txtLegalNameLast.Text 
    AddHandler txtLegalNameLast.TextChanged, AddressOf txtLegalNameLast_TextChanged    

End Sub

編集:上記は私にとってはうまくいきます。私はそれをテストすべきでした。しかし、この非常によく似たコードはそうではありません。Sub の外側の Functions のテキスト ボックスに変更を加えています。これは私にはうまくいきません。

Private Sub txtLegalNameLast_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtLegalNameLast.TextChanged

        RemoveHandler txtLegalNameLast.TextChanged, AddressOf txtLegalNameLast_TextChanged

        txtLegalNameLast.Text = gsCapitalizeTextbox(txtLegalNameLast.Text) 'StrConv(txtLegalNameLast.Text, VbStrConv.ProperCase)
        txtLegalNameLast.Text = gsValidateName(txtLegalNameLast.Text)

        AddHandler txtLegalNameLast.TextChanged, AddressOf txtLegalNameLast_TextChanged

End Sub
4

0 に答える 0