悬停时更改MenuStrip ForeColor

时间:2014-08-14 07:29:13

标签: c# winforms

如何在悬停时更改menuStrip ForeColor?我设法使用以下代码制作背景颜色:

private class MyRenderer : ToolStripProfessionalRenderer
    {
        public MyRenderer() : base(new MyColors()) { }
    }

    private class MyColors : ProfessionalColorTable
    {
        public override Color MenuItemSelected
        {
            get { return Color.Transparent; }

        }
        public override Color MenuItemSelectedGradientBegin
        {
            get { return Color.Transparent; }
        }

        public override Color MenuItemSelectedGradientEnd
        {
            get { return Color.Transparent; }
        }

        public override Color MenuItemBorder
        {
            get { return Color.Transparent; }
        }
    }

现在我只想在悬停它时改变ForeColor。请帮忙

1 个答案:

答案 0 :(得分:1)

    //Assuming black is the forecolor

    private void ToolStripMenuItem1_MouseEnter(object sender, EventArgs e)
    {
        ToolStripMenuItem1.ForeColor = Color.Orange;
    }

    private void ToolStripMenuItem1_MouseLeave(object sender, EventArgs e)
    {
        ToolStripMenuItem1.ForeColor = Color.Black;
    }