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