custom texbox in vb.net.

rajesh.forum

Well-known member
Joined
Sep 7, 2007
Messages
55
Programming Experience
Beginner
hi
I used custom textbox in my application.Now I need to allow special character only once.And also it should not be the starting character.
Next,Only one space should be allowed in between the text which is entered.
Thanks in advance for ur quick reply
with regards
rajesh
 
You override the OnKeyPress method and examine the e.KeyChar property. If it's a character of interest then you examine the text currently in the control to see if it's valid. If it's not then you don't call the base method.

Note that you also take into account the SelectionStart and SelectionLength properties. If SelectionLength is greater than 0 then the selection will be replaced by the incoming character, so that may change things.
 
Back
Top