If I build a simple string like this:
string myStr = "Kayla & William";
And then simply set the label text on a form like this:
lbl_Phrase.Text = myStr;
The output in the form removes the ampersand (&)
I've tried:
When I debug and step through the code the string includes the &
just fine. Also, I can write the string to Debug.WriteLine(myStr);
and it looks great.
Is the problem related to how the form displays the string? How can I get the label to display the &
?
you need to escape it with use double ampersand &&
for displaying single ampersand &
Note : single &
has different meaning that it will be treated as ACCESS KEY PREFIX
character and you need to escape it with another &
Try This :
&&
OR
you can set UseMnemonic
property of the label
to false
, and give only one
ampersand &
.when you set UseMnemonic
to false
ampersand will be treated as normal literal and displayed.
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