|
-
Aug 11th, 2012, 01:52 PM
#1
Thread Starter
Member
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?
-
Aug 11th, 2012, 04:56 PM
#2
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
-
Aug 11th, 2012, 04:59 PM
#3
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)
-
Aug 11th, 2012, 05:34 PM
#4
Thread Starter
Member
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.
-
Aug 11th, 2012, 05:45 PM
#5
Re: modifying functionality of all textboxes in an application?
What is dirty variable mean?
-
Aug 11th, 2012, 06:13 PM
#6
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|