0

I have this code so far for one textbox:

Private Sub Pop1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Pop1.TextChanged
    If String.IsNullOrEmpty(Pop1.Text) Then Pop1.Text = "0,00"
End Sub

I googled there's a need of GotFocus in Handles, but don't know how to do it. Any ideas?

4

1 回答 1

3

Remember that a user might use the tab key to enter or leave the TextBox, so perhaps you want something more like

Private Sub Pop1_Leave(sender As Object, e As EventArgs) Handles Pop1.Leave
    If Pop1.Text = "" Then
        Pop1.Text = "0,00"
    End If
End Sub

Private Sub Pop1_Enter(sender As Object, e As EventArgs) Handles Pop1.Enter
    Pop1.Text = ""
End Sub

You can see the events which are available for a control by selecting it in the designer and looking at the properties pane - click the yellow lightning button to see the events.

于 2012-11-18T17:12:05.800 回答