469,632 Members | 1,698 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,632 developers. It's quick & easy.

rotate control

Hi,

Is it possible to rotate a control on a form ? (e.g. Button, customcontrol)

thnx
Christian
Nov 16 '05 #1
3 13746
Chris,

The most simple format is to set the width larger than the height, however I
assume that you want to rotate it completly.

Normally you should find information about this on the pages from Bob Powell
which are
www.bobpowell.net

The newsgroup where he is very active it not in your crossposting

microsoft.public.dotnet.framework.drawing

What I have seen in this newsgroups is, that after they had implemented GDI+
for this, people where disapointed because there programs became slow. So
keep that in mind.

I hope this helps something?

Cor
"Chris" <ch********@pandora.be> schreef in bericht
news:WM******************@phobos.telenet-ops.be...
Hi,

Is it possible to rotate a control on a form ? (e.g. Button,
customcontrol)

thnx
Christian

Nov 16 '05 #2
Christian,
In addition to the other comments.

If you handle all the painting of the control yourself (as Cor suggested).
You can use Graphics.RotateTransform to rotate the painting surface before
you do any drawing. You may also need to use Graphics.TranslateTransform to
move the origin...

You would need to override the Paint event if they allow it.

Something like:

Imports System.ComponentModel
Imports System.Windows.Forms

Public Class RotatedLabel
Inherits Label

Private m_angle As Integer

Public Sub New()
' Stop the flicker
Me.SetStyle(ControlStyles.UserPaint, True)
Me.SetStyle(ControlStyles.DoubleBuffer, True)
'Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle(ControlStyles.ResizeRedraw, True)
Me.UpdateStyles()
End Sub

<Description("Amount to rotate the text"), _
Category("Appearance"), _
DefaultValue(0)> _
Public Property Angle() As Integer
Get
Return m_angle
End Get
Set(ByVal value As Integer)
m_angle = value
Invalidate()
End Set
End Property

Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
With e.Graphics
.TranslateTransform(MyBase.ClientSize.Width / 2.0F,
MyBase.ClientSize.Height / 2.0F)
.RotateTransform(m_angle)
.Clear(MyBase.BackColor)
Dim brush As New SolidBrush(MyBase.ForeColor)
.DrawString(MyBase.Text, MyBase.Font, brush, 0, 0)
brush.Dispose()
End With
End Sub

End Class

Some controls, such as the TabControl have limited built-in support for
"rotation" for example see TablControl.Alignment.

In addition to Bob Powell's web site the Cor reference, Charles Petzold's
book "Programming Microsoft Windows with Microsoft Visual Basic .NET"
provides a wealth of information on using GDI+.

Hope this helps
Jay

"Chris" <ch********@pandora.be> wrote in message
news:WM******************@phobos.telenet-ops.be...
Hi,

Is it possible to rotate a control on a form ? (e.g. Button,
customcontrol)

thnx
Christian

Nov 16 '05 #3
Hi Chris.

If you want to rotate everything you draw on the control's client area the
other posters gave you the solutions.
If you want to rotate the controls in a fashion where the caption, menus,
caret, buttons are rotated and all the mouse clicks take's into acount
this. I'd say it is impossible.

--
HTH
Stoitcho Goutsev (100) [C# MVP]
"Chris" <ch********@pandora.be> wrote in message
news:WM******************@phobos.telenet-ops.be...
Hi,

Is it possible to rotate a control on a form ? (e.g. Button,
customcontrol)

thnx
Christian

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Tom Hornyak | last post: by
3 posts views Thread by Chris | last post: by
1 post views Thread by Jay | last post: by
8 posts views Thread by lovecreatesbeauty | last post: by
3 posts views Thread by moondaddy | last post: by
3 posts views Thread by Diego F. | last post: by
8 posts views Thread by =?Utf-8?B?RGFu?= | last post: by
13 posts views Thread by =?Utf-8?B?dmlubw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.