Sign in to follow this  

Visual C# Express 2010 Window Forms Inheritance

This topic is 2321 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to set up some Window forms so that news one would inherit from this main one.
In my FormMain design I have all the controls, while FormClasses has no control just the window itself.
Let me know if more code is needed.

FormMain.cs
[code]using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using pLibrary.ItemClasses;
using pLibrary.CharacterClasses;

namespace Editor
{
public partial class FormMain : Form
{
protected static ItemManager ItemManager;
protected static EntityDataManager EntityDataManager;

public FormDetails()
{
InitializeComponent();

if (FormMain.ItemManager == null)
ItemManager = new ItemManager();

if (FormMain.EntityDataManager == null)
EntityDataManager = new EntityDataManager();
}
}
}
[/code]

[code]using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using pLibrary.CharacterClasses;

namespace Editor
{
public partial class FormClasses : FormMain
{
public FormClasses()
{
InitializeComponent();

loadToolStripMenuItem.Click += new EventHandler(loadToolStripMenuItem_Click);
saveToolStripMenuItem.Click += new EventHandler(saveToolStripMenuItem_Click);

btnAdd.Click += new EventHandler(btnAdd_Click);
btnEdit.Click += new EventHandler(btnEdit_Click);
btnDelete.Click += new EventHandler(btnDelete_Click);
}

void loadToolStripMenuItem_Click(object sender, EventArgs e)
{

}

void saveToolStripMenuItem_Click(object sender, EventArgs e)
{

}

void btnAdd_Click(object sender, EventArgs e)
{
using (FormEntityData formEntityData = new FormEntityData())
{
formEntityData.ShowDialog();

if (formEntityData.EntityData != null)
{
lbMain.Items.Add(formEntityData.EntityData.ToString());
}
}
}

void btnEdit_Click(object sender, EventArgs e)
{

}

void btnDelete_Click(object sender, EventArgs e)
{

}
}
}
[/code]

And the problem:
[code]The designer could not be shown for this file because none of the classes within it can be designed.
The designer inspected the following classes in the file:
FormClasses --- The base class 'Editor.FormMain' could not be loaded. Ensure the assembly has been referenced and that all projects have been built.
[/code]

Share this post


Link to post
Share on other sites
Hi,

Your issues come from the fact you have partial classes. Keep in mind [color=#660066][font=CourierNew, monospace][size=2]FormClasses [/size][/font][/color]class is partial and you are extending a partial class ([color=#1C2837][font=CourierNew, monospace][size=2][color=#660066]FormMain[/color][/size][/font][/color]).

[url="http://connect.microsoft.com/VisualStudio/feedback/details/342937/c-partial-class-and-inheritance-of-base-class"]Read[/url]

Share this post


Link to post
Share on other sites

This topic is 2321 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this