Tag Archives: formatting

Display subscripts and superscripts in a RichTextBox in C#, version 2

The following examples show how to display subscripts and superscripts in a RichTextBox. Display subscripts and superscripts in a RichTextBox in C# Easily display subscripts and superscripts in a RichTextBox in C# Those were fairly simple examples, and Sudhir Srivastava … Continue reading

Posted in fonts, formatting | Tagged , , , , , , , , , , , , , | Leave a comment

Use WPF code to display subscripts and superscripts in C#

In the post Display subscripts and superscripts in a WPF TextBlock in C# I mentioned that you could make subscripts and superscripts in WPF code but it was easier in XAML code. Juan Manuel Montes asked for an example, so … Continue reading

Posted in fonts, formatting, wpf, XAML | Tagged , , , , , , , , , , , , , , , , , | Leave a comment

Display subscripts and superscripts in a WPF TextBlock in C#

The following examples show how to display subscripts and superscripts in a RichTextBox in a Windows Forms program. Easily display subscripts and superscripts in a RichTextBox in C# Display subscripts and superscripts in a RichTextBox in C# In a WPF … Continue reading

Posted in fonts, formatting, wpf, XAML | Tagged , , , , , , , , , , , , , , , , , | 1 Comment

Easily display subscripts and superscripts in a RichTextBox in C#

The example Display subscripts and superscripts in a RichTextBox in C# requires you to make arrays holding the positions of the characters that should be subscripts and superscripts. That’s not a big deal but it does require you to count … Continue reading

Posted in fonts, formatting | Tagged , , , , , , , , , , , , , , , | 3 Comments

Display subscripts and superscripts in a RichTextBox in C#

A TextBox can only use a single font at a time so it can’t display subscripts and superscripts, but a RichTextBox can do it. Simply use the control’s Select method to select the text that should be a subscript or … Continue reading

Posted in fonts, formatting | Tagged , , , , , , , , , , , , , | 2 Comments

Use custom numeric formats in C#

You can use formatting characters to display custom numeric formats for numeric values. These formats work with a variable’s ToString method as well as with string.Format. For example, the code (1.234).ToString(“0.00″) returns the value “1.23.” This example builds a ListView … Continue reading

Posted in formatting, strings | Tagged , , , , , , , , , , , , | Leave a comment

Use custom date and time formats in C#

Note that custom date and time formats may not produce the result you want when you program runs in different locales. For example, the date January 23, 2010 should be displayed as 1/23/2010 in the United States but in as … Continue reading

Posted in formatting, strings | Tagged , , , , , , , , , , , , | Leave a comment

Use standard numeric formats in C#

You can use numeric formatting characters to display numbers in particular formats. These formats work with a variable’s ToString method as well as with String.Format. For example, the code value.ToString(“C”) returns the variable value formatted as currency. These formats are … Continue reading

Posted in formatting, strings | Tagged , , , , , , , , , , , , | Leave a comment

Use standard date and time formats in C#

You can use formatting characters to display date and time values in particular formats. These formats work with a variable’s ToString method as well as with String.Format. For example, the code DateTime.Now.ToString(“f”) returns the current date and time in full … Continue reading

Posted in formatting, strings | Tagged , , , , , , , , , , , , , , | 1 Comment

Use the DateTime class’s standard formatting methods in C#

The ToString and string.Format methods let you use formatting characters to format a DateTime value, but it’s not easy to remember all of the characters you might want to use. To make using standard formats easier, the DateTime class provides … Continue reading

Posted in formatting, strings | Tagged , , , , , , , , , , , , , , , | Leave a comment