Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 1.89 KB

how-to-create-vertical-text.md

File metadata and controls

36 lines (26 loc) · 1.89 KB
title ms.date dev_langs helpviewer_keywords ms.assetid description
How to: Create Vertical Text
03/30/2017
csharp
vb
text [Windows Forms], drawing vertical
Windows Forms, drawing vertical text
strings [Windows Forms], drawing vertical
vertical text [Windows Forms], drawing
50c69046-4188-47d9-b949-cc2610ffd337
Learn how to create vertical text using a StringFormat with supporting illustrations, descriptions and links.

How to: Create Vertical Text

You can use a xref:System.Drawing.StringFormat object to specify that text be drawn vertically rather than horizontally.

Example

The following example assigns the value xref:System.Drawing.StringFormatFlags.DirectionVertical to the xref:System.Drawing.StringFormat.FormatFlags%2A property of a xref:System.Drawing.StringFormat object. That xref:System.Drawing.StringFormat object is passed to the xref:System.Drawing.Graphics.DrawString%2A method of the xref:System.Drawing.Graphics class. The value xref:System.Drawing.StringFormatFlags.DirectionVertical is a member of the xref:System.Drawing.StringFormatFlags enumeration.

The following illustration shows the vertical text:

Graphic that shows vertical font text.

[!code-csharpSystem.Drawing.FontsAndText#31] [!code-vbSystem.Drawing.FontsAndText#31]

Compiling the Code

  • The preceding example is designed for use with Windows Forms, and it requires xref:System.Windows.Forms.PaintEventArgs e , which is a parameter of xref:System.Windows.Forms.PaintEventHandler.

See also