问题
So I have a MenuStrip in C# which I am trying to do a darkish theme for, but when I press the button for the dropdown menu well....
Is there a way to make it go from white to another color? I can't seem to figure out a way to do it. This is probably my first time even customizing context menus.
回答1:
You could use MouseHover and MouseLeave event. It's easy. Just do the following steps:
We have a form with these items: http://s3.picofile.com/file/8188577184/Capture.JPG
Choose that dark backcolor for ToolStripMenuItem. I choosed
blackcolor forfileToolStripMenuItemin my example.Use this for
MouseHoverevent:private void fileToolStripMenuItem_MouseHover(object sender, EventArgs e) { fileToolStripMenuItem.BackColor = Color.White; fileToolStripMenuItem.ForeColor =Color.Black; }Use this for
MouseLeaveevent:private void fileToolStripMenuItem_MouseLeave(object sender, EventArgs e) { fileToolStripMenuItem.BackColor = Color.Black; fileToolStripMenuItem.ForeColor = Color.White; }
来源:https://stackoverflow.com/questions/30250663/change-backcolor-of-toolstripitem-on-mouse-over