这两个button事件怎么不听使唤啊
int i_1 = 0;
private void button2_Click(object sender, EventArgs e)
{
if (i_1 > 0)
{
button2.BackColor = Color.White;
i_1 = 0;
return;
}
button2.BackColor = Color.FromArgb(0, 192, 0); ;
button3.BackColor = Color.White;
i_1++;
}
int i_2 = 0;
private void button3_Click_1(object sender, EventArgs e)
{
if (i_2 > 0)
{
button3.BackColor = Color.White;
i_2 = 0;
return;
}
button3.BackColor = Color.FromArgb(0, 192, 0); ;
button2.BackColor = Color.White;
i_2++;
}
窗口中,有两个button按钮,要求实现点击按钮,其背景色就发生变化,并且,二者只能有一个是彩色的,
我这个代码,怎么运行后发现,多点几下,不听使唤,要连点两下,才发生变化,请大师帮忙看看
private void button2_Click(object sender, EventArgs e)
{
if (i_1 > 0)
{
button2.BackColor = Color.White;
i_1 = 0;
return;
}
button2.BackColor = Color.FromArgb(0, 192, 0); ;
button3.BackColor = Color.White;
i_1++;
}
int i_2 = 0;
private void button3_Click_1(object sender, EventArgs e)
{
if (i_2 > 0)
{
button3.BackColor = Color.White;
i_2 = 0;
return;
}
button3.BackColor = Color.FromArgb(0, 192, 0); ;
button2.BackColor = Color.White;
i_2++;
}
窗口中,有两个button按钮,要求实现点击按钮,其背景色就发生变化,并且,二者只能有一个是彩色的,
我这个代码,怎么运行后发现,多点几下,不听使唤,要连点两下,才发生变化,请大师帮忙看看
作者: sdgds53 发布时间: 2011-06-15
这种问题,你走个断点看看,就能立马知道是哪里错了。
作者: wjhgzx 发布时间: 2011-06-15
你说的连点两下,是不是把事件绑到doubleclick上去了啊。。。
作者: wjhgzx 发布时间: 2011-06-15
加上红色的两条语句
int i_1 = 0;
private void button2_Click(object sender, EventArgs e) {
i_2 = 0; if (i_1 > 0) {
button2.BackColor = Color.White;
i_1 = 0;
return;
}
button2.BackColor = Color.FromArgb(0, 192, 0); ;
button3.BackColor = Color.White;
i_1++;
}
int i_2 = 0;
private void button3_Click_1(object sender, EventArgs e) {
i_1 = 0; if (i_2 > 0) {
button3.BackColor = Color.White;
i_2 = 0;
return;
}
button3.BackColor = Color.FromArgb(0, 192, 0); ;
button2.BackColor = Color.White;
i_2++;
}
int i_1 = 0;
private void button2_Click(object sender, EventArgs e) {
i_2 = 0; if (i_1 > 0) {
button2.BackColor = Color.White;
i_1 = 0;
return;
}
button2.BackColor = Color.FromArgb(0, 192, 0); ;
button3.BackColor = Color.White;
i_1++;
}
int i_2 = 0;
private void button3_Click_1(object sender, EventArgs e) {
i_1 = 0; if (i_2 > 0) {
button3.BackColor = Color.White;
i_2 = 0;
return;
}
button3.BackColor = Color.FromArgb(0, 192, 0); ;
button2.BackColor = Color.White;
i_2++;
}
作者: Icedmilk 发布时间: 2011-06-15