如何更改 Windows 应用程序菜单的悬停(鼠标悬停)颜色?
C# 中的任何方法?
或
使用 Windows API (DllImport) 有什么办法吗?
看图:
最佳答案
您正在使用 MenuStrip 类。您可以覆盖其渲染器。这是一个示例,请选择您自己的颜色。
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
menuStrip1.Renderer = new MyRenderer();
}
private class MyRenderer : ToolStripProfessionalRenderer {
public MyRenderer() : base(new MyColors()) {}
}
private class MyColors : ProfessionalColorTable {
public override Color MenuItemSelected {
get { return Color.Yellow; }
}
public override Color MenuItemSelectedGradientBegin {
get { return Color.Orange; }
}
public override Color MenuItemSelectedGradientEnd {
get { return Color.Yellow; }
}
}
}
ProfessionalColorTable 的其他属性控制其他颜色元素。
关于c# - 如何更改菜单悬停颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9260303/