C# -> Windows 新建表单 Window 显示问题
C# -> Windows Form New Window Show Trouble
我正在尝试使用 Windows 表单创建一个新的 window,但出现此错误:
" 'whichDiceGameForm' does not contain a definition for 'show' and no extension method 'show' accepting a first argument of type 'whichDiceGameForm' could be found (are you missing a using directive or an assembly reference?) "
public partial class mainForm : Form
{
public mainForm()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void mainForm_Load(object sender, EventArgs e)
{
title.Font = new Font("Arial", 10, FontStyle.Bold);
}
private void startButton_Click(object sender, EventArgs e)
{
radioDice.Tag = new whichDiceGameForm();
radioCard.Tag = new whichCardGame();
mainForm f = null;
if (radioDice.Checked)
f = new whichDiceGameForm();
else
if (radioCard.Checked)
f = new whichCardGame();
f.Show();
}
}
编辑* 这是 whichDiceGameForm 代码:
public partial class whichDiceGameForm : Form
{
public whichDiceGameForm()
{
InitializeComponent();
}
private void whichDiceGameForm_Load(object sender, EventArgs e)
{
}
}
你写的 "show" 是小写的。第一个字母应大写:"Show"
此外,您还违反了语言约定(class 小写的名称,以大写开头的局部变量...)
我正在尝试使用 Windows 表单创建一个新的 window,但出现此错误:
" 'whichDiceGameForm' does not contain a definition for 'show' and no extension method 'show' accepting a first argument of type 'whichDiceGameForm' could be found (are you missing a using directive or an assembly reference?) "
public partial class mainForm : Form
{
public mainForm()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void mainForm_Load(object sender, EventArgs e)
{
title.Font = new Font("Arial", 10, FontStyle.Bold);
}
private void startButton_Click(object sender, EventArgs e)
{
radioDice.Tag = new whichDiceGameForm();
radioCard.Tag = new whichCardGame();
mainForm f = null;
if (radioDice.Checked)
f = new whichDiceGameForm();
else
if (radioCard.Checked)
f = new whichCardGame();
f.Show();
}
}
编辑* 这是 whichDiceGameForm 代码:
public partial class whichDiceGameForm : Form
{
public whichDiceGameForm()
{
InitializeComponent();
}
private void whichDiceGameForm_Load(object sender, EventArgs e)
{
}
}
你写的 "show" 是小写的。第一个字母应大写:"Show"
此外,您还违反了语言约定(class 小写的名称,以大写开头的局部变量...)