本文介绍了如何更改Windows Forms Application工具条的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Code Project读者,



我不知道如何在点击工具条按钮时更改工具条按钮的背景颜色...



我在工具条中有6个按钮。当我点击第3个按钮时,单独需要突出显示该按钮,直到点击下一个按钮。



先谢谢。

Hi Code Project readers,

I dont know how to change the background color of the toolstrip buttons when it is clicked...

I have 6 buttons in the toolstrip. when i click the 3rd button, that button alone need to be highlighted, till the next button is clicked.

Thanks in Advance.

推荐答案


Color NormalColor = SystemColors.Control;
Color HighlightColor = Color.Orange;

private void ToolStripButton_Click(object sender, EventArgs e)
{
    ToolStripButton tsbtnTemp = sender as ToolStripButton;

    toolStripButton1.BackColor = NormalColor;
    toolStripButton2.BackColor = NormalColor;
    toolStripButton3.BackColor = NormalColor;
    toolStripButton4.BackColor = NormalColor;
    toolStripButton5.BackColor = NormalColor;
    toolStripButton6.BackColor = NormalColor;

    tsbtnTemp.BackColor = HighlightColor;
}


这篇关于如何更改Windows Forms Application工具条的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 23:26