I am trying to get the keydown keybox event to catch the backspace key down event. This works for me by adding a class that overrides the text box. What I do not know how to do is to contact the class where the text field is in the user control.
When the user enters a text field ... say abcd or backspace, I need to update something in usercontrol. let me say that I want to have something that displays the number of characters in the text box. can someone help me. That's what i still have
Option Strict On
Imports System.Text.RegularExpressions
Partial Public Class Page
Inherits UserControl
Public Sub New()
InitializeComponent()
Dim textbox As New MyTextBox() With {.Width = 300, .Height = 100}
LayoutRoot.Children.Add(textbox)
End Sub
End Class
Public Class MyTextBox
Inherits TextBox
Protected Overrides Sub OnKeyDown(ByVal e As KeyEventArgs)
MyBase.OnKeyDown(e)
If e.Key = Key.Back Then
e.Handled = True
MyBase.OnKeyDown(e)
ElseIf e.Key = Key.Delete Then
e.Handled = True
MyBase.OnKeyDown(e)
End If
End Sub
End Class
thanks shannon
source
share