Solved

notifyIcon.Text property does not show '&' char

Posted on 2003-11-19
18
369 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wav problem 4 27
WCF Service Application cannot connect from TCP terminal 1 33
C# LINQ ForEach() question 6 28
Release Dynamically Allocated Memory in C# 3 27
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…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

810 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