Textbox with extra properties

  • Thread starter Thread starter Michel Vanderbeke
  • Start date Start date
M

Michel Vanderbeke

Hello,

I would like to create a textbox with extra properties where I can choose if
the textbox may contain only numbers, only letters, both, punctuation marks
etc.
Can anyone help me with tips how I can realise this?

Many thanks,

Michel
 
Hello,

I would like to create a textbox with extra properties where I can choose if
the textbox may contain only numbers, only letters, both, punctuation marks
etc.
Can anyone help me with tips how I can realise this?

Many thanks,

Michel

1. Create a custom control inheriting from TextBox

2. Add a property to control what type of characters are allowed.

3. Override OnKeyPress and/or OnKeyDown and stop invalid characters
there.

4. Prevent the user from Pasting in invalid characters (can't remember
if the above overrides will handle pasted characters)

5. Do anything I forgot to mention :-)

Will that get you started?

Thanks,

Seth Rowe
 
Back
Top