简体   繁体   English

单击按钮时颜色更改文本

[英]color changing text on button click

I have two buttons in windows forms.我在 Windows 窗体中有两个按钮。 Let's say the text on one button is "WORD".假设一个按钮上的文字是“WORD”。 When that button is clicked, I want the color of the text to change in this order: red, green, blue.单击该按钮时,我希望文本的颜色按以下顺序更改:红色、绿色、蓝色。 I only want it to stop changing colors when the other button is pressed.我只希望它在按下另一个按钮时停止改变颜色。 What would be the best way to acomplish this?实现这一目标的最佳方法是什么?

I don't have much code, but this is what I have:我没有太多代码,但这就是我所拥有的:

        private void Stop_Click(object sender, EventArgs e)
        {

        }

        private void StartButton_Click(object sender, EventArgs e)
        {
            
        }

Use an the EventHandler with the Button.click event and an if-clause将 EventHandler 与 Button.click 事件和 if 子句一起使用

  • mybutton.click += ... mybutton.click += ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM