Category Archives: fonts

Easily draw rotated text on a form in C#

The example Draw rotated text in C# shows how to draw rotated text. Unfortunately that method requires you to use code at run time to position the text. It’s not too hard but it’s inconvenient if you’re trying to draw … Continue reading

Posted in fonts, forms, graphics | Tagged , , , , , , , , , , , , | 1 Comment

Draw numbered buttons and save them into files in C#

This example is very similar to the previous one Draw numbered circles and save them into files in C# except it draws its circles so they look like numbered buttons. The following code shows how the program draws the circles’ … Continue reading

Posted in drawing, fonts, graphics | Tagged , , , , , , , , , , | 4 Comments

Draw numbered circles and save them into files in C#

Sometimes I need to draw numbered circles to place on pictures that I’m going to use in books or articles. This program lets me draw circles that look nice, that are smoothly shaded, and that have transparent backgrounds. The MakeNumberBitmap … Continue reading

Posted in drawing, fonts, graphics | Tagged , , , , , , , , , , | 3 Comments

Set font size to fit a wrapped label in C#

The example Set font size to fit a label in C# shows how you can pick a font size to make text large but still fit inside a Label. This example is similar except it allows the text to wrap … Continue reading

Posted in drawing, fonts, graphics | Tagged , , , , , , , , , , , , , , | Leave a comment

Set font size to fit a label in C#

This program uses the following method to calculate the largest font size that the Label can use while still allowing the sample text to fit. // Return the largest font size that lets the text fit. private float GetFontSize(Label label, … Continue reading

Posted in drawing, fonts, graphics | Tagged , , , , , , , , , , , , | Leave a comment

Draw justified text in C#

The StringFormat class has Alignment and LineAlignment properties that let you draw justified text. They let you specify how you want text aligned vertically and horizontally. The Alignment property determines the text’s horizontal alignment and the LineAlignment property determines its … Continue reading

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

Align numeric values in ComboBox and ListBox controls in C#

The example Sort partly numeric items in a ComboBox or ListBox in C# displays a list of values that begin with numbers. Unfortunately the text doesn’t line up nicely in the result. This example solves that problem by using a … Continue reading

Posted in controls, fonts | 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 , , , , , , , , , , , , , , , | 1 Comment