C#计时器和比赛简易打分winform
2020-12-13 06:08
标签:计时器 比赛打分 分数统计 c#计时器 vs2013 +C#开发的演讲比赛简易打分系统, 可以实现录入选手名称 和评委分数,去掉最高分和最低分后求平均值 然后减去扣分,得到汇总分数. 下面附带"走马灯"字幕滚动和计时器功能. 功能很简单,附上源码,仅供参考,欢迎交流. FORM1 控件截图 namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //打分及排名 private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { Dictionary if (e.ColumnIndex > 0 && e.ColumnIndex { for (int i = 0; i { if (i == 0) { } else if (i == 12 || i == 11) { } else { if (dataGridView1.Rows[e.RowIndex].Cells[i].Value != null) { string str = dataGridView1.Rows[e.RowIndex].Cells[i].Value.ToString(); double d; if (double.TryParse(str, out d)) { dic.Add(i, d); } else { dic.Add(i, 0); } } else { dic.Add(i, 0); } } } double total = 0; foreach (int key in dic.Keys) { total += dic[key]; } if (this.dataGridView1.Rows[e.RowIndex].Cells[11].Value != null) { double d1; if (double.TryParse(this.dataGridView1.Rows[e.RowIndex].Cells[11].Value.ToString(), out d1)) { this.dataGridView1.Rows[e.RowIndex].Cells[12].Value = ((total - dic.Values.Max() - dic.Values.Min()) / 8) - d1; } else { this.dataGridView1.Rows[e.RowIndex].Cells[12].Value = ((total - dic.Values.Max() - dic.Values.Min()) / 8) - 0; } } else { this.dataGridView1.Rows[e.RowIndex].Cells[12].Value = ((total - dic.Values.Max() - dic.Values.Min()) / 8) - 0; } } } //下面为计时加字幕滚动功能 private int t = 0; public string GetAllTime(int time) { string mm, ss, fff; int f = time % 60;//s int s = time / 60; int m = s / 60; //分 s = s % 60;//秒 if (f { fff = "0" + f.ToString(); } else { fff = f.ToString(); } //秒格式00 if (s { ss = "0" + s.ToString(); } else { ss = s.ToString(); } //分格式00 if (m { mm = "0" + m.ToString(); } else { mm = m.ToString(); } //返回 hh:mm:ss.ff return mm + ":" + ss + ":" + fff; } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { } private void btnstar_Click(object sender, EventArgs e) { if (timer1.Enabled == false) { this.btnstar.Text = "暂停计时"; this.timer1.Enabled = true; } else { this.btnstar.Text = "开始计时"; this.timer1.Enabled = false; } } private void timer1_Tick(object sender, EventArgs e) { t = t + 1; this.textBox1.Text = GetAllTime(t); } private void btnclear_Click(object sender, EventArgs e) { t = 0; //如果正在计时,则先停止再清零,否则直接清零 if (this.timer1.Enabled == true) { this.btnstar_Click(sender, e); textBox1.Text = GetAllTime(t); } else { textBox1.Text = GetAllTime(t); } } private void timer2_Tick(object sender, EventArgs e) { string tt = textBox2.Text; string tt1 = tt.Substring(1); string tt2 = tt1 + tt[0]; textBox2.Text = tt2; //dataGridView1.CurrentCell.Value } private void button1_Click(object sender, EventArgs e) { if(timer2.Enabled==true) { button1.Text = "开始滚动字幕"; timer2.Enabled = false; } else { button1.Text = "暂停滚动字幕"; timer2.Enabled = true; } } } } 本文出自 “苕国马龙” 博客,请务必保留此出处http://gaojinghui.blog.51cto.com/3415762/1537047 C#计时器和比赛简易打分winform,搜素材,soscw.com C#计时器和比赛简易打分winform 标签:计时器 比赛打分 分数统计 c#计时器 原文地址:http://gaojinghui.blog.51cto.com/3415762/1537047