C#中的Windows应用 [英] windows applivations in C#
本文介绍了C#中的Windows应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使按钮在单击时从绿色变为红色,从绿色变为红色
how i do make the button to change its color to red from green and from green to red when is clicked
推荐答案
假定button1
是您的按钮
1.在InitializeComponent();
之后添加
Assuming thatbutton1
is your button
1. Add
button1.Click +=new EventHandler(button1_Click);
2.添加方法button1_Click:
after InitializeComponent();
2. Add the method button1_Click:
private void button1_Click(object sender, EventArgs e)
{
if(button1.BackColor == Color.Red)button1.BackColor = Color.Green;
else button1.BackColor = Color.Red;
}
这篇关于C#中的Windows应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文