I have a ContextMenuStrip
which displays items which can be named by the user; the user is allowed to give the items names containing ampersands. When the ContextMenuStrip
is shown, the items' treat the ampersands as escape sequences, and underline the next character.
I could double up all the ampersands before I set the items' Text
members, but that member is used elsewhere in the code so if possible, I'd like to stop the ContextMenuStrip from treating ampersands specially. Is there a way to turn that behaviour off?
use &&
to display a single &
Edit: Sorry, I missed the second part of your question :(
You could always use string.Replace("&", "&&")
on the text when you set it, but that seems messy.
Another alternative would be to inherit from ToolStripMenuItem
and override the Set of the Text Property to replace &
with &&
. That would be a little better as it would keep the code in once place.
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