1
votes

How to change menuStrip ForeColor when hovering it? I've managed to make the background color transpared using this code:

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; }
        }
    }

Now I want just the ForeColor to change when I hover it. Please help

1
@EugenePodskal Its Not duplicate. That question change backcolor. its forecolorSathish
@EugenePodskal no, just the ForeColor I want to changeIan
Understood. But unfortunately I am unable to remove the flag.Eugene Podskal
Proper attribution is required at SO, a link to the original post and a link to the poster's profile.Hans Passant
i think i've found a way, i used the mouseenter and mouseleave events to change the forecolorIan

1 Answers

1
votes
    //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;
    }