Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preventing copy/paste in text boxes

Status
Not open for further replies.

DaveMere

Programmer
Nov 24, 2003
20
GB
Hi all,

I'd like to prevent the input of inappropriate characters to a text box. I have an ascii check on the KeyPress event which weeds out non-numeric and non-alphabetic characters, however it is still possible to add dodgy characters via the paste option on the right-click dropdown menu. Is there a property I can set to prevent pasting into a text box? Or will I have to check the contents of the text box through code?

Cheers,

DaveMere
 
As redsmooth stated, use the Change Event in code. This would be easiest.

There is the possibility to use the EditBox's undo feature (API) (or your own) when the pasted text is incorrect.

Otherwise, you would need to catch the pasting in the KeyDown AND KeyPress AND the PopUp menu.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top