Solved

notifyIcon.Text property does not show '&' char

Posted on 2003-11-19
18
370 Views
Last Modified: 2008-02-01
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?
0
Comment
Question by:glowas
  • 6
  • 6
  • 5
  • +1
18 Comments
 
LVL 9

Expert Comment

by:WinterMuteUK
ID: 9781048
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!
0
 
LVL 9

Expert Comment

by:tinchos
ID: 9781063
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

Tincho
0
 
LVL 9

Expert Comment

by:WinterMuteUK
ID: 9781105
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'
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:glowas
ID: 9781222
I just tried your suggestion
notifyIcon.Text = "M\&G";

Unfortunately it is not working
When mouse cursor is over notifyIcon the text shows:
"M\G"
0
 
LVL 9

Expert Comment

by:WinterMuteUK
ID: 9781245
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.
0
 

Author Comment

by:glowas
ID: 9781265
notifyIcon.UseMnemonic is not a property of System.Windows.Forms.NotifyIcon ????
0
 
LVL 9

Expert Comment

by:tinchos
ID: 9781270
Sorry glowas

Did you try with what I suggested?
0
 
LVL 9

Expert Comment

by:WinterMuteUK
ID: 9781276
Ahh, I wasn't sure, use the '&&' answer of Tincho that'll solve it
0
 

Author Comment

by:glowas
ID: 9781311
notifyIcon.Text=notifyIcon.Text.Repleace("&", "&&");

does not work as well???

I am getting MG but this time G is underlined
0
 
LVL 9

Expert Comment

by:WinterMuteUK
ID: 9781320
Have you just tried:
notifyIcon.Text = "M&&G";
??
0
 

Author Comment

by:glowas
ID: 9781322
for now I do this:
notifyIcon.Text=notifyIcon.Text.Repleace("&", " and ");
 But it is not what I want.

"M and G"
0
 
LVL 9

Accepted Solution

by:
tinchos earned 250 total points
ID: 9781340
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
0
 
LVL 9

Expert Comment

by:WinterMuteUK
ID: 9781341
But why mess around with all the 'text.replace' stuff, why not just set it to "M&&G" initially?
0
 

Author Comment

by:glowas
ID: 9781345
I just did try notifyIcon.Text = "M&&G";

and

I see  MG and G is underlined....  :-((((
0
 
LVL 15

Expert Comment

by:SRigney
ID: 9781376
What type of control is notifyIcon?
0
 
LVL 9

Expert Comment

by:tinchos
ID: 9781387
That's strange I tried with that and worked for me...........

notifyIcon.Text = "M&&G";

and I see "M&G"

:O


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
0
 

Author Comment

by:glowas
ID: 9781413
I don't understand that, but I just tried
notifyIcon.Text = "M&&&G";

and it works

I see "M&G"
0
 
LVL 9

Expert Comment

by:tinchos
ID: 9781453
Wow

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.........

Tincho
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question