notifyIcon.Text property does not show '&' char

I want to set notifyIcon.Text property to "M&G"

notifyIcon.Text = "M&G";

But when I point the mouse over the notify icon I see only "MG"
Why is that? How can I set it to the text I want with '&' char?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you need to use a backslash before hand I think:

so it'd be:

notifyIcon.Text = "M\&G";

Try that and see if it works!
I guess that it is because the & character is used to highligh a letter for fast access

for example in word you press alt and then f and it opens the file submenu.

Try with && instead and it should work

Hope this helps

Actually, on checking that - that answer is wrong... sorry,

I'm not sure what sort of control you are using for : notifyIcon, but if this happened in a label (for example)

label1.text = "M&B";    //displays 'MB'

if you have this beforehand:

label1.UseMnemonic = false;

it will display properly, so you probably need this:

notifyIcon.UseMnemonic = false;
notifyIcon.Text = "M&B"; //displays 'M&B'
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

glowasAuthor Commented:
I just tried your suggestion
notifyIcon.Text = "M\&G";

Unfortunately it is not working
When mouse cursor is over notifyIcon the text shows:
Yep, I thought it might be an escape character, but I was wrong - tinchos got it bang on the head.
Using '&&' instead of just '&' will solve your prob, the 'UseMnemonic' thing will work as well, but it's no where near as concise.
glowasAuthor Commented:
notifyIcon.UseMnemonic is not a property of System.Windows.Forms.NotifyIcon ????
Sorry glowas

Did you try with what I suggested?
Ahh, I wasn't sure, use the '&&' answer of Tincho that'll solve it
glowasAuthor Commented:
notifyIcon.Text=notifyIcon.Text.Repleace("&", "&&");

does not work as well???

I am getting MG but this time G is underlined
Have you just tried:
notifyIcon.Text = "M&&G";
glowasAuthor Commented:
for now I do this:
notifyIcon.Text=notifyIcon.Text.Repleace("&", " and ");
 But it is not what I want.

"M and G"
I had that problem once and it's like this

if you write G then your G appears normal
if you write &G then your G appears underlined (as a shorcut - See post before)
if you write &&G then you get &G

Check what is it that you're getting

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
But why mess around with all the 'text.replace' stuff, why not just set it to "M&&G" initially?
glowasAuthor Commented:
I just did try notifyIcon.Text = "M&&G";


I see  MG and G is underlined....  :-((((
What type of control is notifyIcon?
That's strange I tried with that and worked for me...........

notifyIcon.Text = "M&&G";

and I see "M&G"


make sure there are no spaces in between them

and just to try, try adding another &, but I'm surprised to see that it is not working as I suggested earlier
glowasAuthor Commented:
I don't understand that, but I just tried
notifyIcon.Text = "M&&&G";

and it works

I see "M&G"

Sincerely glowas, I don't know what to tell you............

It worked for me with only two &........ cant figure out why it worked for you with three of them.

Anyway.... glad it worked.........

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.