Link to home
Start Free TrialLog in
Avatar of ah7386
ah7386

asked on

VB.NET - Subclassing exisiting controls

Hi there,

I am quite new to VB.NET, moving over from Visual Foxpro.  In foxpro it was possible to subclass all of the standard windows controls in a class lbrary and then use the subclassed controls to build your forms.

The main benefit is that you can add functionality to the standard controls and adjust there appearance in the subclassed control which would then filter down to the controls throughout your application.

I have built a class library in VB.NET and subclasses all of the controls using the standard...

Public Class myTextBox
 Inherits TextBox

End Class


This works fine and I can add the class library dll to the toolbar - great.  The only problem is, when I alter a control in the class library (say changing a font for example) - the change isnt reflected in the forms that use the control.  In order for this to work I have to remove the controls and add them again!

Am I missing something here?  Has anyone any examples of a control library class that I can look at?

I would really appreciate your help as im getting more and more irritated by some of the .NET functionality! (I wont mention transparent controls!!)

Kind Regards

AH
ASKER CERTIFIED SOLUTION
Avatar of UberDeveloper
UberDeveloper

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ah7386
ah7386

ASKER

Thanks for the post - it helped me solve my problem.  If I remember correctly there is an option in the properties of the reference (mycontrols.dll for example) you can tell .NET not to copy the control to the application directory - i think this will force VB to update the reference automatically - I cant remember the exact details as im not at my work PC at the moment.

Anyhow - many thanks for your detailed response.

PS - when your altering fonts etc.  Which event do you use to put your:

 font = new font("Tahoma")

code in? - the NEW or the OnCreateControl event?

Thanks

AH
I'm not sure about that one...The thing I like about creating my own controls is that I can make my own properties and then just set them from the properties window....Sorry


-Tim