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?
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
Re: modifying functionality of all textboxes in an application?
vb.net Code:
Public Class TextBoxMod
Inherits TextBox
'all your extra stuff
End Class
Now replace your textboxes with an instance of your class.
vb.net Code:
Dim txb As TextBoxMod = New TextBoxMod
With txb
.BorderStyle = BorderStyle.None
.Enabled = True
.Width = 150
.Height = 20
.Location = New Point(100, 100)
.Visible = True
End With
Me.Controls.Add(txb)
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.
Re: modifying functionality of all textboxes in an application?
What is dirty variable mean?
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.