禁用ToolStripMenuItem高亮显示? [英] Disable ToolStripMenuItem highlight?

查看:143
本文介绍了禁用ToolStripMenuItem高亮显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有MenuStrip的应用程序,每次将鼠标悬停在MenuItem上时,它都会突出显示为蓝色.

I have an application with a MenuStrip and every time I hover my mouse over a MenuItem, it highlights blue.

我试图更改BackColor和ForeColor,但这不是问题.

I have tried to change the BackColor and ForeColor but that wasn't the problem.

是否可以禁用此功能?

推荐答案

这对于最终用户将毫无用处:

This would be incredibly un-useful to the end user:

internal class NoHighlightRenderer : ToolStripProfessionalRenderer {
  protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) {
    if (e.Item.OwnerItem == null) {
      base.OnRenderMenuItemBackground(e);
    }
  }
}

然后将其应用于您的MenuStrip:

Then apply it to your MenuStrip:

menuStrip1.Renderer = new NoHighlightRenderer();

这篇关于禁用ToolStripMenuItem高亮显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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