Disable ToolStripMenuItem highlight?

只愿长相守 提交于 2019-12-12 17:01:36

问题


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

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

Is there a way to disable this?


回答1:


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

Then apply it to your MenuStrip:

menuStrip1.Renderer = new NoHighlightRenderer();


来源:https://stackoverflow.com/questions/26508662/disable-toolstripmenuitem-highlight

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!