Reputation: 31
created a form that inherits from another form, but for some reason I am getting the error constructor on type "baseForm" not found. This is the inheriting class constructor:
public partial class loadHtmlFormsDatabaseForm : NEA_Official.createHtmlFormsForm
{
List<field> listOfFields = new List<field>();
static string username1;
int originalListOfFieldsCount;
htmlFormsProject loadedProject;
public loadHtmlFormsDatabaseForm(htmlFormsProject loadProject, string username) : base(username1)
{
username1 = username;
loadedProject = loadProject;
InitializeComponent();
}
This is the constructor for the base class:
public partial class createHtmlFormsForm : Form
{
List<field> listOfFields = new List<field>();
string username = "";
public createHtmlFormsForm(string username1)
{
username = username1;
InitializeComponent();
}
Upvotes: 3
Views: 2105
Reputation: 581
You can fix it by overload the constructor with no parameter in base class like this:
public partial class createHtmlFormsForm : Form
{
List<field> listOfFields = new List<field>();
string username = "";
public createHtmlFormsForm(string username1)
{
username = username1;
InitializeComponent();
}
public createHtmlFormsForm()
{
InitializeComponent();
}
}
If you don't need constructor with no parameter you can create it private :
public partial class createHtmlFormsForm : Form
{
List<field> listOfFields = new List<field>();
string username = "";
public createHtmlFormsForm(string username1)
{
username = username1;
InitializeComponent();
}
// private contructor with no parameter
private createHtmlFormsForm()
{
InitializeComponent();
}
}
or you can use Obsolete Attribute:
public partial class createHtmlFormsForm : Form
{
List<field> listOfFields = new List<field>();
string username = "";
public createHtmlFormsForm(string username1)
{
username = username1;
InitializeComponent();
}
[Obsolete("Designer only", true)]
public createHtmlFormsForm()
{
InitializeComponent();
}
}
Upvotes: 7
Reputation: 3634
it foud but send wrong parameter.
: base(username1)
change to : base(username)
Upvotes: 0