日期:2014-05-20 浏览次数:21040 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TpSystem
{
public partial class Form1 : Form
{
//各人的票数
private int num1 = 0;
private int num2 = 0;
private int num3 = 0;
public Form1()
{
InitializeComponent();
label1.Text = "张三:";
label2.Text = "李四:";
label3.Text = "王五:";
//设置三个按钮的样式
foreach (Control c in this.Controls)
{
if (c.GetType() == typeof(Button))
{
Button btn = (Button)c;
btn.BackColor = Color.Red;
btn.Width = 15;
btn.TextAlign = ContentAlignment.MiddleLeft;
btn.FlatAppearance.BorderSize = 0;
btn.FlatStyle = FlatStyle.Flat;
btn.Click += new EventHandler(btn_Click);
}
}
showNumber();
//button1.s
}
void btn_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
switch (btn.Name)
{
case "button1":
{
num1 += 1;
break;
}
case "button2":
{
num2 += 1;
break;
}
case "button3":
{
num3 += 1;