Show an “&” (ampersand) in Button or Label Text in C# – Programming, Pseudocode Example, C# Programming Example
Basic Windows Form

Show an “&” (ampersand) in Button or Label Text in C#

How would one enter special characters into a Label or Button in C# Windows Form?

First Way:

Display & in button text, use &&. A single & is used for keyboard shortcuts, and a double ampersand will escape that.

 

Second Way:

Set UseMnemonic for that label to false. This causes all ampersands within the text to be taken literally so you don’t need to double any of them. You’ll lose the underlining and access key features though.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.