winFroms 桌面应用程序开发 窗体应用程序 参考一下各位是怎么做的
1条回答 默认 最新
- 浪客 2022-06-10 15:43关注
public partial class Form1 : Form { public Form1() { InitializeComponent(); } int num; private void Form1_Load(object sender, System.EventArgs e) { txtNum.MaxLength = 1; txtNum.TabIndex = 0; labLimit.ForeColor = System.Drawing.Color.Blue; System.Drawing.Font font = new System.Drawing.Font("微软雅黑", 16); labLimit.Font = font; timerLimit.Interval = 1000; labTime.ForeColor = System.Drawing.Color.Orange; labTime.Font = font; timerTime.Interval = 1000; timerTime.Start(); } int limit = 9; private void timerLimit_Tick(object sender, System.EventArgs e) { labLimit.Text = limit.ToString(); limit--; if (limit < 0) limit = 9; } private void timerTime_Tick(object sender, System.EventArgs e) { labTime.Text = System.DateTime.Now.ToString("HH:mm:ss"); } private void btnStart_Click(object sender, System.EventArgs e) { System.Random rnd = new System.Random(); num = rnd.Next() % 10; timerLimit.Start(); } private void btnStop_Click(object sender, System.EventArgs e) { if (txtNum.Text.Length == 0) return; timerLimit.Stop(); if (num == int.Parse(txtNum.Text)) { MessageBox.Show("猜对了"); } else { MessageBox.Show("猜错了"); } } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录
悬赏问题
- ¥15 CSS通配符清除内外边距为什么可以覆盖默认样式?
- ¥15 SPSS分类模型实训题步骤
- ¥15 求解决扩散模型代码问题
- ¥15 工创大赛太阳能电动车项目零基础要学什么
- ¥20 limma多组间分析最终p值只有一个
- ¥15 nopCommerce开发问题
- ¥15 torch.multiprocessing.spawn.ProcessExitedException: process 1 terminated with signal SIGKILL
- ¥15 QuartusⅡ15.0编译项目后,output_files中的.jdi、.sld、.sof不更新怎么解决
- ¥15 pycharm输出和导师的一样,但是标红
- ¥15 想问问富文本拿到的html怎么转成docx的