473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Easy question - for veterans :-)

Jim
I thought this would be a fairly basic...

How do you include an ampersand "&" in a form title, menu, or just a label
text?

Because "&" and "&&" are part of the language, I've tried "\&", "\u0026",
and just about everything else I can think of.

Ended up just using "and" but it was a thron, so I spent hours looking in
the .NET documentation and google searches trying to figure it out. I've
concluded it is either not possible or so simple everybody else already
knows how to do it.

Nov 17 '05 #1
5 2240
Jim <PR***************@PRIVATEacoffice.comPRIVATE> wrote:
I thought this would be a fairly basic...

How do you include an ampersand "&" in a form title, menu, or just a label
text?

Because "&" and "&&" are part of the language, I've tried "\&", "\u0026",
and just about everything else I can think of.
They're part of the language when used outside a string, but "&" is
just a string literal.
Ended up just using "and" but it was a thron, so I spent hours looking in
the .NET documentation and google searches trying to figure it out. I've
concluded it is either not possible or so simple everybody else already
knows how to do it.


You can use normal C# keywords within string literals with no problem.

See http://www.pobox.com/~skeet/csharp/s....html#literals for what
you *do* need to escape.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
button.Text = "Save && Exit";

You have to double the ampersand because ampersand is used (by Windows, not
by the language) to specify keyboard accelerators:

button.Text = "&Save"; // will underline the S and bind ALT-S to the button.

Bruno.

"Jim" <PR***************@PRIVATEacoffice.comPRIVATE> a écrit dans le message
de news: eL**************@TK2MSFTNGP09.phx.gbl...
I thought this would be a fairly basic...

How do you include an ampersand "&" in a form title, menu, or just a label
text?

Because "&" and "&&" are part of the language, I've tried "\&", "\u0026",
and just about everything else I can think of.

Ended up just using "and" but it was a thron, so I spent hours looking in
the .NET documentation and google searches trying to figure it out. I've
concluded it is either not possible or so simple everybody else already
knows how to do it.

Nov 17 '05 #3
The problem is that in a label & denotes that the following letter which is the keyboard shortcut for the next control in the tab order (it puts an underscore against it). Use && e.g

Label l = new Label();
l.Text = "Hello && Goodbye";

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Jim <PR***************@PRIVATEacoffice.comPRIVATE> wrote:
I thought this would be a fairly basic...

How do you include an ampersand "&" in a form title, menu, or just a label
text?

Because "&" and "&&" are part of the language, I've tried "\&", "\u0026",
and just about everything else I can think of.
They're part of the language when used outside a string, but "&" is
just a string literal.
Ended up just using "and" but it was a thron, so I spent hours looking in
the .NET documentation and google searches trying to figure it out. I've
concluded it is either not possible or so simple everybody else already
knows how to do it.


You can use normal C# keywords within string literals with no problem.

See http://www.pobox.com/~skeet/csharp/s....html#literals for what
you *do* need to escape.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

[microsoft.public.dotnet.languages.csharp]
Nov 17 '05 #4
Just escape it with another & character. For eg, 'Save && Exit' will show as
'Save & Exit'. However, this is not required for window captions.

"Jim" <PR***************@PRIVATEacoffice.comPRIVATE> wrote in message
news:eL**************@TK2MSFTNGP09.phx.gbl...
I thought this would be a fairly basic...

How do you include an ampersand "&" in a form title, menu, or just a label
text?

Because "&" and "&&" are part of the language, I've tried "\&", "\u0026",
and just about everything else I can think of.

Ended up just using "and" but it was a thron, so I spent hours looking in
the .NET documentation and google searches trying to figure it out. I've
concluded it is either not possible or so simple everybody else already
knows how to do it.


Nov 17 '05 #5
Richard Blewett [DevelopMentor] <ri******@NOSPAMdevelop.com> wrote:
The problem is that in a label & denotes that the following letter
which is the keyboard shortcut for the next control in the tab order
(it puts an underscore against it). Use && e.g

Label l = new Label();
l.Text = "Hello && Goodbye";


Right - I realised there might be something to do with that just after
sending the reply, but I had to go and preach somewhere, so never added
the extra bit :)

However, again it doesn't matter that && is an operator in C# itself -
as part of a string, it's fine.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Russ Perry Jr | last post by:
I'm using "ID" and "Value" in the generic sense here... Let's say one page I had a <html:select> with a collection like this: <html:options collection="items" property="key"...
0
by: PatchFactory Support | last post by:
Description: Professional and easy-to-use patch building environment that can help you to create instant patch packages for software and file updating. Generated patch packages are small size...
4
by: NBURGAN | last post by:
We are currently searching for a reporting tool with graphics for our end users who are using Oracle's standard edition. We are not using the Oracle's AS. The tool needs to be easy to use and...
19
by: Canon EOS | last post by:
Hi, I am really new in .net and pocket PC development. My background are purely C/C++/VC++. Have developed on Mobile Java for a year and felt completely insecure with it because all codes can...
8
by: Adam Clauss | last post by:
I have a folder containing many subfolders (and subfolders and....) all containing various .cs files. Is there any "easy" way to get them all added to the solution. Preferable would be that the...
2
by: Thomas | last post by:
Hi, I there anybody here that are designing applications with asp.net without html in aspx files? The problem is that aspx files is a dependency, and I would like to avoid having that...
5
by: LedZep | last post by:
What up, All I need to do is enter a last name in a text box, query a MSAccess database and display the name with the corresponding columns. This is no problem, but when there are more than one...
1
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
10
by: Victor Bazarov | last post by:
Just asking...
409
by: jacob navia | last post by:
I am trying to compile as much code in 64 bit mode as possible to test the 64 bit version of lcc-win. The problem appears now that size_t is now 64 bits. Fine. It has to be since there are...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.