C# 中 两个按钮 点击按钮一 按钮2颜色变蓝 再点击按钮1 按钮2变红色 如此循环 求代码
2个回答
展开全部
private bool m_Flag = false;
private void button4_Click(object sender, EventArgs e)
{
if (!m_Flag)
{
button5.BackColor = Color.Blue;
m_Flag = true;
}
else
{
button5.BackColor = Color.Red;
m_Flag = false;
}
}
private void button4_Click(object sender, EventArgs e)
{
if (!m_Flag)
{
button5.BackColor = Color.Blue;
m_Flag = true;
}
else
{
button5.BackColor = Color.Red;
m_Flag = false;
}
}
追问
如果是改变图标呢 怎么去写路径
追答
private bool m_Flag = false;
private void button4_Click(object sender, EventArgs e)
{
if (!m_Flag)
{
button5.BackColor = Color.Blue;
button5.Image = RawSocket.Properties.Resources.未命名01;
m_Flag = true;
}
else
{
button5.BackColor = Color.Red;
button5.Image = null;
m_Flag = false;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询