Issue with form_load
本文关键字:load form with Issue | 更新日期: 2023-09-27 18:35:34
我正在尝试使某些标签按钮等在加载时可见,但是,当我单击表单并返回它时,form_load代码再次激活。 就好像它是一个onClick事件而不是加载。
我对编码完全陌生,所以这可能是非常简单的事情
非常感谢
private void formCanvas_Load(object sender, EventArgs e)
{
lblUsed.Visible = false;
lblScore.Visible = false;
lblUsedLetters.Visible = false;
lblGuessWord.Visible = false;
lblUserChoice.Visible = false;
lblWord.Visible = true;
txtUserLetter.Visible = false;
txtUserWord.Visible = true;
btnSubmitWord.Visible = true;
btnSubmitLetter.Visible = false;
lblLives.Visible = false;
btnExit.Visible = false;
btnRestart.Visible = false;
}
你应该把代码放在formCanvas类的构造函数上
public formCanvas()
{
InitializeComponent();
lblUsed.Visible = false;
lblScore.Visible = false;
lblUsedLetters.Visible = false;
lblGuessWord.Visible = false;
lblUserChoice.Visible = false;
lblWord.Visible = true;
txtUserLetter.Visible = false;
txtUserWord.Visible = true;
btnSubmitWord.Visible = true;
btnSubmitLetter.Visible = false;
lblLives.Visible = false;
btnExit.Visible = false;
btnRestart.Visible = false;
}