Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Rotate Label text 90 degree?

7 views
Skip to first unread message

Mark Gaeth

unread,
Nov 7, 2003, 8:42:28 PM11/7/03
to
Hi,

I have looked high and low and wondered if there is a way for the Label
text property of the font to be rotated 90 degrees. I can do it in CR and
Excel but wondered if there was a trick to doing the same with a font
property in VB.Net.

Mark Gaeth
Decatur, IN


Bob Powell [MVP]

unread,
Nov 8, 2003, 4:10:58 AM11/8/03
to
You can easily create a control to display text and rotate it in the OnPaint
override.

The StringFormat class provides one method of rotating text using the
StringFormatFlags.DirectionVertical enumeration member. The other is to use
a transform. The latter method enables you to rotate the text vertically in
either direction. ie. top to left or top to right.

--
Bob Powell [MVP]
C#, System.Drawing

The October edition of Well Formed is now available.
Find out how to use DirectX in a Windows Forms control
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Mark Gaeth" <mga...@mchsi.com> wrote in message
news:8SXqb.141013$Tr4.369163@attbi_s03...

Mark Gaeth

unread,
Nov 8, 2003, 6:52:49 AM11/8/03
to
Thanks Bob,

I am a new at this game and I will see if I can find out how to make it work
in VB.Net. I am trying to make a operations program for my model railroad
layout. I am a true novice and find programming a fun spare time hobby.

Mark

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:%23dBiDhd...@TK2MSFTNGP12.phx.gbl...

Herfried K. Wagner [MVP]

unread,
Nov 8, 2003, 6:57:48 AM11/8/03
to
* "Mark Gaeth" <mga...@mchsi.com> scripsit:

> I have looked high and low and wondered if there is a way for the Label
> text property of the font to be rotated 90 degrees. I can do it in CR and
> Excel but wondered if there was a trick to doing the same with a font
> property in VB.Net.

You can draw text in any angle:

\\\
Private Sub Form1_Paint( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs _
) Handles MyBase.Paint
e.Graphics.RotateTransform(20)
e.Graphics.DrawString("Hello World!", Me.Font, Brushes.Blue, 0, 0)
End Sub
///

Maybe you want to derive a class from 'Label', extend it by an 'Angle'
property and add custom drawing code.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

TB

unread,
Nov 8, 2003, 9:02:18 PM11/8/03
to
A followon question to both you and Herfried...

How could one draw with a rotated baseline but non-rotated characters. I.e.
the equivalent of creating a font with non-equal escapement and orientation
values in GDI?

I would like to label a button with the letters appearing top to bottom, but
each character oriented normally. How can I do this?

-- TB

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:%23dBiDhd...@TK2MSFTNGP12.phx.gbl...

0 new messages