Solved

notifyIcon.Text property does not show '&' char

Posted on 2003-11-19
18
373 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 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