Solved

notifyIcon.Text property does not show '&' char

Posted on 2003-11-19
18
364 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:glowas
Comment Utility
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
Comment Utility
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
Comment Utility
notifyIcon.UseMnemonic is not a property of System.Windows.Forms.NotifyIcon ????
0
 
LVL 9

Expert Comment

by:tinchos
Comment Utility
Sorry glowas

Did you try with what I suggested?
0
 
LVL 9

Expert Comment

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

Author Comment

by:glowas
Comment Utility
notifyIcon.Text=notifyIcon.Text.Repleace("&", "&&");

does not work as well???

I am getting MG but this time G is underlined
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 9

Expert Comment

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

Author Comment

by:glowas
Comment Utility
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
Comment Utility
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
Comment Utility
But why mess around with all the 'text.replace' stuff, why not just set it to "M&&G" initially?
0
 

Author Comment

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

and

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

Expert Comment

by:SRigney
Comment Utility
What type of control is notifyIcon?
0
 
LVL 9

Expert Comment

by:tinchos
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now