此代码的新 Form1() 部分(此代码在我的 Main.cs 中)不断给我这个错误 - HomeInventory2.Form1 不包含采用 0 个参数的构造函数。
private void cDsToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = new Form1();
// show the form
form.Show();
}
Form1代码如下
namespace HomeInventory2
{
public partial class Form1 : Form
{
public Form1(IEnumerable<string> prepopulated)
{
InitializeComponent();
IEnumerable<String> lines = prepopulated;
textBoxAmount.Text = lines.ElementAtOrDefault(0);
textBoxCategories.Text = lines.ElementAtOrDefault(1);
textBoxProperties.Text = lines.ElementAtOrDefault(2);
textBoxValue.Text = lines.ElementAtOrDefault(3);
}
private void label1_Click(object sender, EventArgs e)
{
}
private void submitButton_Click(object sender, EventArgs e)
{
CreateInventory create = new CreateInventory();
create.ItemAmount = textBoxAmount.Text;
create.ItemCategory = textBoxCategories.Text;
create.ItemProperties = textBoxValue.Text;
create.ItemValue = textBoxValue.Text;
InventoryMngr invtryMngr = new InventoryMngr();
invtryMngr.Create(create);
}
}
}
我尝试在其中放置一个空白构造函数 - 但是当然当调用该按钮或菜单项时,它只会显示一个空白屏幕。