110,571
社区成员
发帖
与我相关
我的任务
分享
private void buttons_Click(object sender, EventArgs e)
{
Color c = ((Button)sender).BackColor;
for (int i = 0; i < 5; i++)
{
buttons[i].BackColor = c;
}
((Button)sender).BackColor = (c == Color.Red ? Color.DeepSkyBlue : Color.Red);
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
Button btn = null;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
((Button)sender).BackColor = Color.DeepSkyBlue;
if (btn != null)
btn.BackColor = Color.Red;
btn = (Button)sender;
}
}
}