CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2002
    Posts
    41

    Can I modify the existing textbox class?

    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

  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured