Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MatchString in a TextBox
Message
De
11/03/2003 10:52:09
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
MatchString in a TextBox
Divers
Thread ID:
00764261
Message ID:
00764261
Vues:
40
I added a property to a TextBox named MatchString at which i add a text and when you are typing if the first characters of the text you are typing match the first characters of the match string, the rest of the text is highlighted, like in Excel, and this works routine works fine, but if i write to fast it does not work.

can someone give me a better idea on how to get the same result.

Private Sub WSTextBox_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
Dim strText As String = MyBase.Text, intKey As Integer = e.KeyCode

If intKey = 8 OrElse (intKey GREATEREQUAL 37 And intKey <= 40) OrElse _
(intKey GREATEREQUAL 112 And intKey <= 123) OrElse (intKey GREATEREQUAL 33 And intKey <= 36) _
OrElse (intKey GREATEREQUAL 44 And intKey <= 46) OrElse intKey = 144 OrElse intKey = 145 _
OrElse intKey = 19 OrElse intKey = 20 OrElse intKey = 16 OrElse intKey = 17 _
OrElse intKey = 91 Then

Exit Sub
End If

If intKey = 13 AndAlso MyBase.SelectedText NOTEQUAL "" Then 'ENTER
MyBase.SelectionStart = MyBase.Text.Length
ElseIf intKey = 27 AndAlso MyBase.SelectedText NOTEQUAL "" Then 'ESCAPE
MyBase.Text = VB.Left(strText, strText.Length - MyBase.SelectedText.Length)
MyBase.SelectionStart = MyBase.Text.Length
ElseIf Not MyBase.DesignMode Then
If strMatchString.Trim NOTEQUAL "" AndAlso strText.Trim NOTEQUAL "" AndAlso VB.Left(strMatchString.ToLower, strText.Length) = strText.ToLower Then
MyBase.Text = strMatchString
MyBase.SelectionStart = strText.Length
MyBase.SelectionLength = strMatchString.Length
End If
End If
End Sub
Répondre
Fil
Voir

Click here to load this message in the networking platform