Inherited textbox


Mar 23, 2005
Programming Experience
I am trying to use Inherited Controls to create textboxes derived from the standard one. Those textboxes will have different appearance and different behaviour (in the event handler).

when using the Inherited textbox in a new form, I see the visual differences but it doesn't allow to type anything in it (as if they were blocked).

My goal is that both visualisation properties and behaviour (event handler) are defined in the inherited control, leaving the controls in the forms with no code behind...

May I get some advice, please?

having derived textboxes that behave the same way in events like "Validated", "Validating"... I will write the handlers for the inherited textbox. The forms (several dozens, say) containing the inherited controls will have NO CODE attached to it, because they will execute the handler of the "parent" (so, just write the code once, instead of many times). So I am not overriding anything in the final code of theinherited controls

events to override:
pòssibly "validated" "validating"

code: see zip file, Form1 and inhtbxA are the form and the inherited control, form tmtMaint plays no role in this example


    31.1 KB · Views: 57
I have tested all this stuff using an UserControl instead of a inherited textbox, and it seems to work

maybe I would have to upgrade my VS2003 Pro to some Service Packs???
Inherited control (/Solved/)

I found the solution looking at MSDN. Events in classes are to be declared

Protected Overrides Sub OnValidated( ….

And not

Private Sub TextBox1_Validating( ………


This effectively causes the textbox to behave as I desire

Additionally, the clause Inherits shoud be

Public Class MyTextbox
Inherits System.Windows.Forms.TextBox

instead of

Public Class MyTextbox
Inherits System.Windows.Forms.control

thanks to all for your interest