Tag Archives: align text

Make an owner-drawn ListBox that justifies columns in C#

This example shows how you can use an owner-drawn ListBox to left and right align values in columns. The following examples show different ways to align values in columns. Draw aligned columns of data in C# Format values in a … Continue reading

Posted in controls, fonts, graphics, lists, user interface | Tagged , , , , , , , , , , , , , , , , , , | Leave a comment

Draw aligned columns of data in C#

This example draws a series of rows with aligned columns either left or right justified. The program uses the following code to define the data it will draw and the row and column alignments. // The values. private string[][] Values … Continue reading

Posted in fonts, graphics, lists | Tagged , , , , , , , , , , , , , , , | 1 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

Align text drawn by DrawString in C#

This example shows how to use StringFormat objects and Rectangles to align text drawn in in C#. This example’s Paint event handler draws nine strings inside a rectangle, aligning them vertically and horizontally in the nine possible combinations of top/left, … Continue reading

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