Search code examples
c#vb.netwinformscode-duplication

Is it possible to add a reference to some source code to include in a source file in vb.net, winforms?


I don't know what this is called so I've struggled to find an answer from google but I have a vague memory of it from t'old days.

I've sub-classed (* see below) about 8 framework controls, overriden some properties and added some functionality into each one. The changes I have made are identical in every case. If I make a change, I have to go through each class and apply the same change there. I was hoping there may be a keyword such as <IncludeSourcefile "common.vb> that I can put into each class.

Any chance?

(* note) I use the term sub-classed but I don't know if that's the correct terminology. I've also seen it used for call-backs. Is sub-classed the correct term to use?


Solution

  • I seriously doubt that's going to work out for you. You can't use an include file to jam the changes into the derived controls. You'd normally make the changes in a common base class, one derived from Control for example, then derive individual controls from that base class. But that's not going to work if you customized 8 separate control classes. Copy-and-paste is your lot.