Results 1 to 6 of 6

Thread: modifying functionality of all textboxes in an application?

Hybrid View

  1. #1
    Member RHankinsJr's Avatar
    Join Date
    Nov 11
    Location
    Texarkana, TX
    Posts
    47

    Question modifying functionality of all textboxes in an application?

    I have an application I wrote where the end users are requesting some additional functionality to every text box in the system.

    I know how to do it on a form level or individual part level, but I was curious if there is a way to add it without adding code to each form.

    I seem to recall someone once showing us here how to add to a class where it it modifies all objects of that class.

    Can anyone point me in the right direction?

  2. #2
    Frenzied Member
    Join Date
    Sep 06
    Posts
    1,255

    Re: modifying functionality of all textboxes in an application?

    Create your won text box by inheriting TextBox

    Code:
    Public Class MyTextBox
        Inherits System.Windows.Forms.TextBox
        
        ' add your new Methods, Properties and events
        
    End Class

  3. #3
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 12
    Posts
    5,507

    Re: modifying functionality of all textboxes in an application?

    vb.net Code:
    1. Public Class TextBoxMod
    2.     Inherits TextBox
    3.  
    4.     'all your extra stuff
    5.  
    6. End Class

    Now replace your textboxes with an instance of your class.

    vb.net Code:
    1. Dim txb As TextBoxMod = New TextBoxMod
    2.         With txb
    3.             .BorderStyle = BorderStyle.None
    4.             .Enabled = True
    5.             .Width = 150
    6.             .Height = 20
    7.             .Location = New Point(100, 100)
    8.             .Visible = True
    9.         End With
    10.         Me.Controls.Add(txb)

  4. #4
    Member RHankinsJr's Avatar
    Join Date
    Nov 11
    Location
    Texarkana, TX
    Posts
    47

    Re: modifying functionality of all textboxes in an application?

    Hmm, thanks. That's not exactly what I was talking about. Maybe I'm mistaken but the example I was talking about actually extended the textbox control itself. Now that I am typing this I remember it was an example showing how to extend all the text box controls to include a dirty variable. Now that I remember that I'll do some more searching and find it. Thank you all for your help.

  5. #5
    Frenzied Member
    Join Date
    Sep 06
    Posts
    1,255

    Re: modifying functionality of all textboxes in an application?

    What is dirty variable mean?

  6. #6
    Member RHankinsJr's Avatar
    Join Date
    Nov 11
    Location
    Texarkana, TX
    Posts
    47

    Re: modifying functionality of all textboxes in an application?

    The example was showing how to extend all text boxes in the system to have a boolean variable that told if the contents of the control have changed since it was populated with data. I will for some searching, I think it was in the codebank on here. Thanks again. I will do some searching once I get at an actual PC now that I remember what the example was about. Thanks again.

Posting Permissions

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