views:

35

answers:

3

I am developing an application that needs some kind of subscript and superscript support to display text that refers to chemical formula, if I do it in a textbox (winforms) and want for example show water formula, it would appear as H20 rather than H(subscript 2)O (sorry I coudn't find how to do it here). How could this be done? Thanks.

A: 

Consider using the RichTextBox

Nescio
+1  A: 

Run the Windows Charmap.exe applet. Tick the Advanced view checkbox and in the Search for box type "two". You should see the "Subscript two" glyph, Unicode codepoint '\u2082'. Click Select and Copy. Switch to your code or the Properties window and type "H" + Ctrl+V + "O" to get "H₂O".

Hans Passant
A: 

Each TextBox can display any unicode words. the only limitation is that by the QWERTY keyboards (that have simple and daily characters) you wont be able to insert Subscript

What's the solution?

You have to use a keyboard Layout that implement these chemical glyphs as characters. it should be Unicode. I'm not sure that you can find such a keyboard layout.

What's the Alternative?

You can use some tools that enables you to write text in unicode and then copy the final text into the Textbox and Save and show it to User.

Windows CharMap is one ofthe simplest tools you can use. but in each time you can only copy one character to your textbox.

I suggest you to use Unicode Converter, it is an open source tools hostedby codeplex and let you create complicated texts and then you can copy the final result into your textbox.

Important Notes

Each character you use, has a glyph on a specific font. the most complited Unicode font I ever seen is Arial Unicode MS Regular that is an extention for Arial so I strongly recomand to use this font in this case. If you are using another font you should make sure that your client install it on their system.

Nasser Hadjloo