如何更改菜单悬停颜色 [英] How to change menu hover color

查看:141
本文介绍了如何更改菜单悬停颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改Windows应用程序菜单的哈弗(鼠标)颜色?

How to change the Hover (mouse over) color of a Windows application menu?

在C#中的任何方法?

使用Windows API的任何方式(的DllImport)?

请参阅图:

推荐答案

您正在使用的MenuStrip类。您可以覆盖其渲染器。下面是一个例子,选择自己的颜色吧。

You are using the MenuStrip class. You can override its renderer. Here's an example, pick your own colors please.

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

的<一个其它性能href=\"https://msdn.microsoft.com/en-us/library/System.Windows.Forms.ProfessionalColorTable(v=vs.110).aspx\">ProfessionalColorTable控制其他色彩元素。

这篇关于如何更改菜单悬停颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆