Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

notifyIcon.Text property does not show '&' char

Posted on 2003-11-19
18
Medium Priority
?
374 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

705 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