【发布时间】:2017-05-22 22:23:29
【问题描述】:
我是 stackoverflow 的新手,所以请原谅任何协议违规行为。 我正在尝试使用 c# 为我的孙女编写一个“时间表”练习程序。我对编程很陌生(刚刚过了“Hello World”阶段)。我设置了一个“问候”表单,在该表单中询问用户(我的孙女,通常但不总是)她的名字,并且在按下 Enter 键时,会看到一个包含友好消息和单击请求的文本框如果她想“玩”,请在消息上。如果她点击,她会被带到一个组合框,在那里她可以选择一个“游戏”。我想在那个文本框上附加一个计时器,如果她在 5 秒内没有点击,它会显示另一个文本框。我已经将计时器附加到表单并启用它,但无法确定下一步该做什么。这是我到目前为止的代码:
private void playerOneNameTextbox_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
greetingsTextbox.Visible = true;
greetingsTextbox.Text = "Hi, " + playerOneNameTextbox.Text +
". It's good to see you. Click here if you'd like to play with us";
timer1.Enabled = true;
/*If there is no click within five seconds,
*another textbox should become visible offering another chance to click.
*/
}
private void greetingsTextbox_Click(object sender, EventArgs e)
{
youHaveClickedLabel.Visible = true;
chooseGameComboBox.Visible = true;
}
如果这个问题过于冗长,请致歉 - 如果是,请告诉我,我下次会尽量简洁。非常感谢。
【问题讨论】: