473,410 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

rotate control

Hi,

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

thnx
Christian
Nov 17 '05 #1
3 1230
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 17 '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 17 '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 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: taccea | last post by:
Hello, I need to rotate some text vertically on an Access report. Is that something difficult to do? Any pointers appreciated. Taccea
3
by: Chris | last post by:
Hi, Is it possible to rotate a control on a form ? (e.g. Button, customcontrol) thnx Christian
1
by: Jay | last post by:
I'm wondering if anyone has even encountered a control or other scripting that will automatically rotate the rows of a datagrid... I am in the process of building an asp.net application that will...
1
by: Rohan | last post by:
Hi There, Is it possible to rotate or resize pictureboxes, labels, textboxes at runtime? And I even wanted to make textbox and label controls Transperent ?
8
by: lovecreatesbeauty | last post by:
I write a function to rotate a matrix by 90 degrees clockwise, this function works on a matrix of specific size, for example, it rotates a 4*4 matrix of integers in the following code. The function...
1
by: iwdu15 | last post by:
hi, i need to rotate a string (ex, make it upside down and if it was on the top, make it on the bottom of my control). the string is drawn on using GDI, so i looked at the Transform property, the...
3
by: moondaddy | last post by:
I'm working in a WPF windows application and am wondering if it's possible to rotate a Canvas or user control derived from Canvas. I created a user control which derives from Canvas and I need to...
3
by: Diego F. | last post by:
Hi all. I have a listview with images and my application must be able to rotate one image. I need a method to rotate 90 degrees rigth (i.e.). Is that possible? -- Regards, Diego F.
8
by: =?Utf-8?B?RGFu?= | last post by:
I would like to draw an ellipse on a windows form and through mouse drags stretch, rotate and relocate the ellipse. Thanks in advance - Dan
13
by: =?Utf-8?B?dmlubw==?= | last post by:
Hello, I have created my proper control and i would to rotate it. In the paint event of my object, i have written : Dim graph As Graphics = myObject.CreateGraphics myMatrix = New...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.