Click to See Complete Forum and Search --> : Can I modify the existing textbox class?


cgchris99
October 17th, 2002, 12:32 PM
I have about 100 textboxes on a form and they are in various tabs.
I have had to add the following handlers to perform some code that I want on these events.

Is there a way to modify the existing Textbox class to include these changes so I don't have to add this code 100 times for each of the textboxes on the form?

You will notice the Procedure for TextBoxChanged is the same for every textbox on the form and so is TextBoxValidated, TextboxMouseDown, etc.

Thanks for any help

AddHandler txtTextBox1.TextChanged, AddressOf TextBoxChanged
AddHandler txtTextBox1.Validated, AddressOf TextBoxValidated
AddHandler txtTextBox1.MouseDown, AddressOf TextBoxMouseDown
AddHandler txtTextBox1.Leave, AddressOf TextBoxLeave
AddHandler txtTextBox1.KeyPress, AddressOf TextBoxKeypress

AddHandler txtTextBox2.TextChanged, AddressOf TextBoxChanged
AddHandler txtTextBox2.Validated, AddressOf TextBoxValidated
AddHandler txtTextBox2.MouseDown, AddressOf TextBoxMouseDown
AddHandler txtTextBox2.Leave, AddressOf TextBoxLeave
AddHandler txtTextBox2.KeyPress, AddressOf TextBoxKeypress

DSJ
October 17th, 2002, 04:24 PM
You cant' change the default textbox, but you can inherit from it and create your own class and modify that. I think that would be easier than your current approach 'cause then you could search and replace "as TextBox = new TextBox" with "as YourClass = New Yourclass" and be done.