Groups | Blog | Home
all groups > dotnet windows forms > june 2003 >

dotnet windows forms : text box


Hechmi
6/27/2003 3:12:41 PM
Hello,
I have a text box in which I want that a user can only write a number or the
character 'x' but I can't do that
could any one help me please thank you

Hechmi
6/27/2003 3:29:43 PM
thank you Herfied,
But are there any way to prevent him to write some characters.


[quoted text, click to view]

Herfried K. Wagner
6/27/2003 9:21:15 PM
Hello,

"Hechmi" <hkhlifi/@dialexia.com> schrieb:
[quoted text, click to view]

The best solution is to allow any input and check it in the textbox's
Validating event.

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet

Herfried K. Wagner
6/27/2003 9:35:20 PM
Hello,

"Hechmi" <hkhlifi/@dialexia.com> schrieb:
[quoted text, click to view]

This will prevent the user from typing an "A":

\\\
Private Sub TextBox1_KeyPress( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs _
) Handles TextBox1.KeyPress
If e.KeyChar = "A" Then
e.Handled = True
End If
End Sub
///

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet

AddThis Social Bookmark Button