Tag Archives: StringFormat

Use StringFormat to align text in columns in C#

My previous post Use tabs and StringFormat to align text in C# showed how to use a StringFormat object to draw tab-delimited text in columns. Unfortunately, that method doesn’t give you control over how the values in each column are … Continue reading

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

Use tabs and StringFormat to align text in C#

This example shows how you can use a StringFormat object to align tab-delimited text when drawing it on a window. The Graphics class’s DrawString method draws a string on a window, PictureBox, Bitmap, or other drawing surface. The DrawString method … Continue reading

Posted in fonts, graphics, strings | 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

See how much text fits in a rectangle in C#

This program determines how much text fits in the left PictureBox and draws it. It then draws the remaining text in the right PictureBox. If you change the form’s size, the size of the PictureBox controls change so how much … Continue reading

Posted in fonts, graphics, strings | 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