Typically the hotkey letters on a MenuStrip are underlined. (&File, &Open, etc) On a project I'm working on the underline shows up in the designer, but not at run time. I can't find the property that controls this. Anyone out there know?
You can force the user to see the underline by creating a custom ToolStrip renderer. It took me quite a while to figure out how to bypass Chris's answer. Here is the renderer I created:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace YourNameSpace
{
class CustomMenuStripRenderer : ToolStripProfessionalRenderer
{
public CustomMenuStripRenderer() : base() { }
public CustomMenuStripRenderer(ProfessionalColorTable table) : base(table) { }
protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
{
e.TextFormat &= ~TextFormatFlags.HidePrefix;
base.OnRenderItemText(e);
}
}
}
And then in the Form with the MenuStrip, in the constructor you set the renderer:
public YourFormConstructor()
{
InitializeComponents();
menuStripName.Renderer = new CustomMenuStripRenderer();
}
I would like to note that if you prefer a System style look of renderering you can extend the ToolStripSystemRenderer class instead of the Professional but I like being able to customize the color table. This is the fix that doesn't require the client to change his computer settings. Enjoy!
In Windows, there is a setting whether or not to show the underline. To change the setting,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With