c# - 禁用 ToolStripMenuItem 突出显示?

标签 c# winforms menustrip toolstripmenu

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

我曾尝试更改 BackColor 和 ForeColor,但这不是问题所在。

有没有办法禁用它?

最佳答案

这对最终用户来说毫无用处:

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

然后将其应用到您的 MenuStrip:

menuStrip1.Renderer = new NoHighlightRenderer();

关于c# - 禁用 ToolStripMenuItem 突出显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26508662/

相关文章:

c# - 如何在以编程方式与控件交互后防止事件触发?

C++ - 显示和存储日语字符

带有 native Windows 渲染器的 .NET MenuStrip?

c# - 如何查找带有名称的 toolstripmenuItem

c# - 无边框 move 窗口

c# - 在连接字符串密码中使用非 ASCII 字符

c# - 为什么我需要一个评估者而不是直接从我的绑定(bind)对象数据属性中获取我的值

c# : Why is a cast needed from an Enum to an INT when used in a switch statement? ,枚举是整数

c# - Cocoa (MonoMac) & WinForms (or WPF) frontend with common c# backend

c# - 设置 cell.ReadOnly 无效