Parent Class Winform?

General Fear

Member
Joined
Dec 22, 2012
Messages
12
Programming Experience
10+
I am using VB 2010.

Recently I have had good success with custom controls. I am able to create a parent control like a command button that contains all preferences to our application. I use my own custom controls instead of what ships with Microsoft. Because I am using custom controls, I can make one change, in the parent and all of the children of that use that class benefit from the change. For example, if I change the background color, all of the child command buttons are instantly changed with the new background color.

Now I want to do the same with forms. I have tried "visual inheritance" and it is not working out. Basically, I want to create a parent form that contains all preferences and code required by the application. Then whenever I create a new form I use the parent form template. When I make a change to the parent class I want that change to filter down to all of it's children forms.

So, just like a custom control, how do I create a WinForm parent class with VB 2010?
 
Design your parent form as usual. In standard and pro edition of VS you can use inheritance picker when creating a new inherited form: How to: Inherit Forms Using the Inheritance Picker Dialog Box
For VB Express edition you have to create a new empty form and go to designer code and change the Inherits statement manually (Solution Explorer, show all files, open theForm.Designer.vb).
 
Classes with Windows Forms?

I am using VB.Net 2010.

I am creatig custom controls. The reason I am doing this is because if I create a parent textbox. Then all children textbox will inherit the parents attributes. If later I decide to make a change, then I only have to change it once at the parent level, and all the children textbox will inherit the new change.

I wanted to do the same thing with forms. We have 54 forms in our application. I wanted to create a parent form that way if some future date I have to say change the company logo, I change it once in one location and all 54 forms will inherit the change.

What's the best way to do this with VB 2010.

P.S.

I tried the inherit form route and it seems buggy. I get an error message that reads "No Build assemblies contain compenents to inherit from." I have tried to google and bing this and I have not found a solution.
 
Does the previous reply not answer your question?
 
Does the previous reply not answer your question?



Sorry for the double post everyone. I don't know how that happened.

I tried the visual inheritance picker. But it has problems. I get an error message that reads:
"No Build assemblies contain compenents to inherit from. Build the current applcation or click on Browse and select a peviously built assembly from another application"

I tried to find an answer to the problem on the Net but it only returned 1 reply. Imagine that, whenever you google something you get millions of responces. Not this time. That said, if I can avoid the Visual Inheritance Picker, the better.
 
I'm using VB Express which don't have inheritance picker, so I can't tell you if it has "issues". The picker just lets you select the form to inherit from, and puts "Inherits selectedForm" in the new form (in its .designer.vb partial class) rather than the default "Inherits System.Windows.Forms.Form". Whether you select the form to inherit from or write the Inherits statement yourself is the same.
 
Back
Top