Ich möchte geben nur Zahlen und erlaubt keine Nicht-Nummern, bitte helfen Sie mir damit.Erlaube nur die Zahlen in PasswordBox in WPF
dieser Kodex in TextBox Aber es funktioniert nicht mit PasswordBox
Dim textBox As TextBox = TryCast(sender, TextBox)
Dim selectionStart As Int32 = textBox.SelectionStart
Dim selectionLength As Int32 = textBox.SelectionLength
Dim newText As [String] = [String].Empty
Dim count As Integer = 0
For Each c As [Char] In textBox.Text.ToCharArray()
If [Char].IsDigit(c) OrElse [Char].IsControl(c) Then
newText += c
End If
Next
textBox.Text = newText
textBox.SelectionStart = If(selectionStart <= textBox.Text.Length, selectionStart, textBox.Text.Length)
danke
Warum nicht setzen, was Sie bisher versucht haben? Von Kopf bis Fuß möchte ich die Passwort-Box für die Keypad- und Keydown-Ereignisse abonnieren und Sie können dort nachsehen, ob das letzte Zeichen eine numerische Option war. –
Ich legte den Code, der mit mir in TextBox arbeitete – shhada