Form inheritance - how is it achieved?


Author
Message
Peter Jones
Peter Jones
Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi,

I was hoping I could create a "base" SF Maintenance form that will contain standard code and components, e.g. DefaultLookAndFeel, then inherit this form whenever I create a new form. I have my base form called frmBase_01 and, the code in my test form that is trying use the base form is:

Public Class frmBase_02
   Inherits TMS_Test_01.frmBase_01
End Class

 This generate the error:
"Error 1 Base class 'frmBase_01' specified for class 'frmBase_02' cannot be different from the base class 'MicroFour.StrataFrame.UI.Windows.Forms.StandardForm' of one of its other partial types. C:\Documents and Settings\pmj\My Documents\Visual Studio 2005\Projects\TMS_Test_01\TMS_Test_01\frmBase_02.vb"

Try as I may I just can't stumble my way past this error - can you please point me in the right direction. The recent work I've done with creating a "base" BO class works great but I notice that, for forms, the inheritence is in the partial class - I guess this is a fundemental difference that stops my base BO approach working when trying to achieve the same outcome for a form.

Cheers, Peter

Replies
Peter Jones
Peter Jones
Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Guys,

Thanks for the help - I'm currently working my way through Ivan's feedback. I've extracted the existing template and copy/pasted info from my new form then zipped up the files into a new, uniquely named, zip file and copies it back into: C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\VisualBasic.

I didn't know what was meant by Trent's instruction to go the Visual Studio command prompt but Google to the rescue and I followed the Start>Programs>Visual Studio 2005>Visual Studio Tools and found the command prompt in there. I click this and simply ended up in command window in C:\program files\Microsoft Visual Studio 8\VC. Given that my code is VB I changed the directory to: ..\VB and entered devenv.exe /setup. This seemed to run ok but when I started VS again the only templates I have are: Inherited Form and Inherited User Control.

Contary to all instructions I paniced and went back into the ..\VB directory and entered the devenv command again. No errors but still no templates. I then checked the event log which told me the command I needed was devenv/installvstemplates. However doing this in both the VC and VB directories had no effect.

Any clues on how I recover from this self inflicted wound?


Ivan, specifically on what you have done - its seems to be great approach but have you ever tried changing ProFilmeNET_Base.UI.Windows.Forms.PFNStandardForm and seen the changes perculate through on a rebuild of your app?


Cheers, Peter

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Any clues on how I recover from this self inflicted wound?

Hi Peter, have you seen Pertti's post? http://forum.strataframe.net/Topic7973-10-1.aspx


Ivan, specifically on what you have done - its seems to be great approach but have you ever tried changing ProFilmeNET_Base.UI.Windows.Forms.PFNStandardForm and seen the changes perculate through on a rebuild of your app?

Yes, I have. So far, so good. But I'm not talking about visual inheritance, which seems to be a problem in VS.

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
A template is nice, Peter, but to answer the question in your first post, if you want to create a form with some basic code and then inherit that form by other forms, you can do exactly like you wanted within the first post.  Your only snag was that in each of the partial classes (that includes the .designer.vb file which was probably missed), you have to add the same inherits line.  Or, you can leave the inherits line off and only add it to one of the files (which is what .NET does by default by adding the inherits line to only the .designer.vb file).  The main reason you missed it was probably because the way silly VB hides most of the files within your project by default (as if MS thinks a VB programmer would be scared by seeing so many files in his solution explorer or something).  So, you have to go turn on the "Show All Files" button at the top of the Solution Explorer in order to see the .designer.vb file where the other Inherits line is.

So, if anyone answered this question in the tons of posts on this thread, thanks, but I was just skimming the thread and it didn't looked like all of the discussion was around templates.  Templates are great, and we have several for our projects, but all of our forms also inherit from a base form that is specific to the application... so you really need both.

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Also, if you're making a custom template, then it's a lot easier to put the code in your "My Templates" folder than to put it in with all of the installed templates.  Do this:

Put the .zip file for the template in {My Documents}\Visual Studio 2005\Templates\ItemTemplates\Visual Basic.  This folder is much more user friendly than the other one for several reasons:

1)  Your template shows up under it's own grouping called "My Templates" at the bottom of the Add New Item dialog, not mixed in with all of the others.

2)  You don't have to close Visual Studio, call devenv.exe /setup and then reopen visual studio... just re-open the Add New Item dialog and the template will be re-read.

When we do a custom template for use with one of our commercial products, we don't generally put it in the folder with all of the installed templates for those reasons.  It's a whole lot easier to tweak your template if you don't constantly have to close VS to run devenv.exe /setup just to reinstall your template Smile

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
One last thing... there's an Export Template Wizard that can be reached from the File menu... it will get you 90-100% of the way there on creating a custom template.  Just get the form the way you want it then run through the wizard and it will create the .zip file and dump it into your "My Templates" folder.  It's a lot faster than copying an existing template and modifying it... unless you've done it lots of times, even then the wizard is probably still faster Wink

If you can't reach the wizard from the file menu, then you'll have to add the command to your menu by right-clicking somewhere on the toolbars within VS and choose Customize... at the bottom.  The "Export Template..." command is under the File category.  Just drag it out onto the toolbar or menu where you want it.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Peter Jones - 18 Years Ago
Ivan George Borges - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Greg McGuffey - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Greg McGuffey - 18 Years Ago
Peter Jones - 18 Years Ago
Peter Jones - 18 Years Ago
Ivan George Borges - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Greg McGuffey - 18 Years Ago
Peter Jones - 18 Years Ago
Ivan George Borges - 18 Years Ago
StrataFrame Team - 18 Years Ago
StrataFrame Team - 18 Years Ago
                         One last thing... there's an Export Template Wizard that can be...
StrataFrame Team - 18 Years Ago
Peter Jones - 18 Years Ago
             Hey Peter. Glad to hear that. ;)
Ivan George Borges - 18 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search