how can I write a super or sub char in string

Recommended Answers

short answer: you can't.

long answer: superscript and subscript are font properties, a string only stores characters, it doesnt store any formatting data.

You would need to apply the subscript or superscript when you display the text, in a label/terxtbox/printed format/etc. This is when you would apply the …

Jump to Post

All 3 Replies

short answer: you can't.

long answer: superscript and subscript are font properties, a string only stores characters, it doesnt store any formatting data.

You would need to apply the subscript or superscript when you display the text, in a label/terxtbox/printed format/etc. This is when you would apply the sub/super scripting. You could use a character to denote which letters should be super/sub script. Then parse the string to find the special markers when formatting for display. Something like string superSub = "this ^super^ string is |sub| par" Then when you display the string you search for sections between '^'s and superscript it and subscript anything between '|'s.
You can check out FontVariants over at msdn for one way to apply the formatting.

can you show it more clear in windows application at textbox

I think with a usual texbox this will be hard. Better use a RichTextBox instead.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.