Numeric Data Entry in WPF

前端 未结 17 2541
情话喂你
情话喂你 2020-12-02 05:38

How are you handling the entry of numeric values in WPF applications?

Without a NumericUpDown control, I\'ve been using a TextBox and handling its PreviewKeyDown eve

17条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 05:50

    Private Sub Value1TextBox_PreviewTextInput(ByVal sender As Object, ByVal e As TextCompositionEventArgs) Handles Value1TextBox.PreviewTextInput
        Try
            If Not IsNumeric(e.Text) Then
                e.Handled = True
            End If
        Catch ex As Exception
        End Try
    End Sub
    

    Worked for me.

提交回复
热议问题