473,386 Members | 1,804 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,386 software developers and data experts.

[VB 2008] Rotate a control

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 System.Drawing.Drawing2D.Matrix
myMatrix.Rotate(45, System.Drawing.Drawing2D.MatrixOrder.Append)
graph.Transform = myMatrix

but it don't work.
The object i have created (a 2D wall of a house) no rotate.
If someone say how to resolve it.

Thanks.

Jun 27 '08 #1
13 5336
"vino" <al*******@discussions.microsoft.comschrieb:
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 System.Drawing.Drawing2D.Matrix
myMatrix.Rotate(45, System.Drawing.Drawing2D.MatrixOrder.Append)
graph.Transform = myMatrix

but it don't work.
The object i have created (a 2D wall of a house) no rotate.
You have to set the transformation on the 'Graphics' object you are using to
draw the content, typically in 'OnPaint' or the 'Paint' event handler.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jun 27 '08 #2
Thank you Herfried K. Wagner for your answer.

But i have any idea how to do it.
The rotation value is set by the user and he can change it whenever and my
personal component has to rotate immediately.

Thanks.
Jun 27 '08 #3
On Jun 17, 11:49*am, vino <alex_v...@discussions.microsoft.comwrote:
Thank you Herfried K. Wagner for your answer.

But i have any idea how to do it.
The rotation value is set by the user and he can change it whenever and my
personal component has to rotate immediately.

Thanks.
BTW, what type is your object to be rotated? A kind of standard
control in toolbox?

Thanks,

Onur Güzel
Jun 27 '08 #4
No, it is a personalised control i have made named "Fenetre" and imported in
my project.
It contain an object PowerPacks.RectangleShape and a Label whose represent a
house windows.

Thanks.

Gilles Lautrou.
BTW, what type is your object to be rotated? A kind of standard
control in toolbox?

Thanks,

Onur Güzel
Jun 27 '08 #5
"vino" <al*******@discussions.microsoft.comschrieb:
No, it is a personalised control i have made named "Fenetre" and imported
in
my project.
It contain an object PowerPacks.RectangleShape and a Label whose represent
a
house windows.
Windows Forms controls unfortunately cannot be rotated. However, you can
rotate WPF-based controls.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jun 27 '08 #6
Ok.
If i understand, unfortunately i have to work with WPF.
I have ever tryied it but it seems to be difficult to learn how to
manipulate objects.
If you are a few complete samples of WPF i am interested in.

Thanks.

Gilles

"Herfried K. Wagner [MVP]" wrote:
Windows Forms controls unfortunately cannot be rotated. However, you can
rotate WPF-based controls.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jun 27 '08 #7
On 2008-06-17, vino <al*******@discussions.microsoft.comwrote:
Ok.
If i understand, unfortunately i have to work with WPF.
I have ever tryied it but it seems to be difficult to learn how to
manipulate objects.
If you are a few complete samples of WPF i am interested in.

Thanks.

Gilles

"Herfried K. Wagner [MVP]" wrote:
>Windows Forms controls unfortunately cannot be rotated. However, you can
rotate WPF-based controls.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Here is rotating a button 90 degrees in WPF...

<Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="Hi This is a button">
<Button.LayoutTransform>
<RotateTransform Angle="90" />
</Button.LayoutTransform>
</Button>

Copy this into a tool like XamlPad and you will have a button centered and
rotated 90 degrees...

--
Tom Shelton
Jun 27 '08 #8
On Jun 17, 6:12 pm, Tom Shelton <tom_shel...@comcastXXXXXXX.net>
wrote:
On 2008-06-17, vino <alex_v...@discussions.microsoft.comwrote:
Ok.
If i understand, unfortunately i have to work with WPF.
I have ever tryied it but it seems to be difficult to learn how to
manipulate objects.
If you are a few complete samples of WPF i am interested in.
Thanks.
Gilles
"Herfried K. Wagner [MVP]" wrote:
Windows Forms controls unfortunately cannot be rotated. However, you can
rotate WPF-based controls.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Here is rotating a button 90 degrees in WPF...

<Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="Hi This is a button">
<Button.LayoutTransform>
<RotateTransform Angle="90" />
</Button.LayoutTransform>
</Button>

Copy this into a tool like XamlPad and you will have a button centered and
rotated 90 degrees...

--
Tom Shelton
I got a primitive idea, if you need to rotate a button just for 90
degrees, replace height and width. For example a newly placed button
is sized about 75;23. Then you can do:

Button1.Size = New Size(23, 75)

..and now it seems like it's rotated by 90 degrees. :)

Thanks,

Onur Güzel
Jun 27 '08 #9
On 2008-06-17, kimiraikkonen <ki*************@gmail.comwrote:
On Jun 17, 6:12 pm, Tom Shelton <tom_shel...@comcastXXXXXXX.net>
wrote:
>On 2008-06-17, vino <alex_v...@discussions.microsoft.comwrote:
Ok.
If i understand, unfortunately i have to work with WPF.
I have ever tryied it but it seems to be difficult to learn how to
manipulate objects.
If you are a few complete samples of WPF i am interested in.
Thanks.
Gilles
"Herfried K. Wagner [MVP]" wrote:
>Windows Forms controls unfortunately cannot be rotated. However, you can
rotate WPF-based controls.
>--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Here is rotating a button 90 degrees in WPF...

<Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="Hi This is a button">
<Button.LayoutTransform>
<RotateTransform Angle="90" />
</Button.LayoutTransform>
</Button>

Copy this into a tool like XamlPad and you will have a button centered and
rotated 90 degrees...

--
Tom Shelton

I got a primitive idea, if you need to rotate a button just for 90
degrees, replace height and width. For example a newly placed button
is sized about 75;23. Then you can do:

Button1.Size = New Size(23, 75)

..and now it seems like it's rotated by 90 degrees. :)

Thanks,

Onur Güzel
Except that the content is not rotated...

--
Tom Shelton
Jun 27 '08 #10
On Jun 17, 6:32 pm, Tom Shelton <tom_shel...@comcastXXXXXXX.net>
wrote:
On 2008-06-17, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Jun 17, 6:12 pm, Tom Shelton <tom_shel...@comcastXXXXXXX.net>
wrote:
On 2008-06-17, vino <alex_v...@discussions.microsoft.comwrote:
Ok.
If i understand, unfortunately i have to work with WPF.
I have ever tryied it but it seems to be difficult to learn how to
manipulate objects.
If you are a few complete samples of WPF i am interested in.
Thanks.
Gilles
"Herfried K. Wagner [MVP]" wrote:
Windows Forms controls unfortunately cannot be rotated. However, you can
rotate WPF-based controls.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Here is rotating a button 90 degrees in WPF...
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="Hi This is a button">
<Button.LayoutTransform>
<RotateTransform Angle="90" />
</Button.LayoutTransform>
</Button>
Copy this into a tool like XamlPad and you will have a button centered and
rotated 90 degrees...
--
Tom Shelton
I got a primitive idea, if you need to rotate a button just for 90
degrees, replace height and width. For example a newly placed button
is sized about 75;23. Then you can do:
Button1.Size = New Size(23, 75)
..and now it seems like it's rotated by 90 degrees. :)
Thanks,
Onur Güzel

Except that the content is not rotated...

--
Tom Shelton
Yes, you need to wrap the text of button though it's wrapped
automatically but i found out that "t" seems double as next in a 23;75
sized button with default Sans-Serif Font(8 pt).

Thanks,

Onur Güzel
Jun 27 '08 #11
On 2008-06-17, kimiraikkonen <ki*************@gmail.comwrote:
On Jun 17, 6:32 pm, Tom Shelton <tom_shel...@comcastXXXXXXX.net>
wrote:
>On 2008-06-17, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Jun 17, 6:12 pm, Tom Shelton <tom_shel...@comcastXXXXXXX.net>
wrote:
On 2008-06-17, vino <alex_v...@discussions.microsoft.comwrote:
Ok.
If i understand, unfortunately i have to work with WPF.
I have ever tryied it but it seems to be difficult to learn how to
manipulate objects.
If you are a few complete samples of WPF i am interested in.
Thanks.
Gilles
"Herfried K. Wagner [MVP]" wrote:
>Windows Forms controls unfortunately cannot be rotated. However, you can
rotate WPF-based controls.
>--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
>Here is rotating a button 90 degrees in WPF...
><Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="Hi This is a button">
<Button.LayoutTransform>
<RotateTransform Angle="90" />
</Button.LayoutTransform>
</Button>
>Copy this into a tool like XamlPad and you will have a button centered and
rotated 90 degrees...
>--
Tom Shelton
I got a primitive idea, if you need to rotate a button just for 90
degrees, replace height and width. For example a newly placed button
is sized about 75;23. Then you can do:
Button1.Size = New Size(23, 75)
..and now it seems like it's rotated by 90 degrees. :)
Thanks,
Onur Güzel

Except that the content is not rotated...

--
Tom Shelton

Yes, you need to wrap the text of button though it's wrapped
automatically but i found out that "t" seems double as next in a 23;75
sized button with default Sans-Serif Font(8 pt).

Thanks,

Onur Güzel
The wpf version actually rotates the text as well - not just wraps it into a
column. Here is a complete example that spins a button 360 degrees over a
half a second when it is clicked - and it uses NO procedural code....

<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<Grid>
<Button HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="Hi This is a button"
RenderTransformOrigin=".5,.5">
<Button.LayoutTransform>
<RotateTransform Angle="0" />
</Button.LayoutTransform>
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard TargetProperty="LayoutTransform.Angle">
<DoubleAnimation From="0" To="360" Duration="0:0:.5"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Button.Triggers>
</Button>
</Grid>
</Page>

I have to wonder sometimes, why people are still using Windows forms at all :)
Actually, I know why - but, WPF is so much nicer.

--
Tom Shelton
Jun 27 '08 #12
On Jun 17, 7:40*pm, Tom Shelton <tom_shel...@comcastXXXXXXX.net>
wrote:
On 2008-06-17, kimiraikkonen <kimiraikkone...@gmail.comwrote:


On Jun 17, 6:32 pm, Tom Shelton <tom_shel...@comcastXXXXXXX.net>
wrote:
On 2008-06-17, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Jun 17, 6:12 pm, Tom Shelton <tom_shel...@comcastXXXXXXX.net>
wrote:
On 2008-06-17, vino <alex_v...@discussions.microsoft.comwrote:
Ok.
If i understand, unfortunately i have to work with WPF.
I have ever tryied it but it seems to be difficult to learn how to
manipulate objects.
If you are a few complete samples of WPF i am interested in.
Thanks.
Gilles
"Herfried K. Wagner [MVP]" wrote:
Windows Forms controls unfortunately cannot be rotated. *However, you can
rotate WPF-based controls.
--
*M S * Herfried K. Wagner
M V P *<URL:http://dotnet.mvps.org/>
*V B * <URL:http://dotnet.mvps.org/dotnet/faqs/>
Here is rotating a button 90 degrees in WPF...
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="Hi This is a button">
* * * * <Button.LayoutTransform>
* * * * * * * * <RotateTransform Angle="90" />
* * * * </Button.LayoutTransform>
</Button>
Copy this into a tool like XamlPad and you will have a button centered and
rotated 90 degrees...
--
Tom Shelton
I got a primitive idea, if you need to rotate a button just for 90
degrees, replace height and width. For example a newly placed button
is sized about 75;23. Then you can do:
Button1.Size = New Size(23, 75)
..and now it seems like it's rotated by 90 degrees. :)
Thanks,
Onur Güzel
Except that the content is not rotated...
--
Tom Shelton
Yes, you need to wrap the text of button though it's wrapped
automatically but i found out that "t" seems double as next in a 23;75
sized button with default Sans-Serif Font(8 pt).
Thanks,
Onur Güzel

The wpf version actually rotates the text as well - not just wraps it intoa
column. *Here is a complete example that spins a button 360 degrees overa
half a second when it is clicked - and it uses NO procedural code....

<Page
* * * * xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
* * * * xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
* * * * <Grid>
* * * * <Button HorizontalAlignment="Center"
* * * * * * * * VerticalAlignment="Center"
* * * * * * * * Content="Hi This is a button"
* * * * * * * * RenderTransformOrigin=".5,.5">
* * * * * * <Button.LayoutTransform>
* * * * * * * * <RotateTransform Angle="0" />
* * * * * * </Button.LayoutTransform>
* * * * * * <Button.Triggers>
* * * * * * * * <EventTrigger RoutedEvent="Button.Click">
* * * * * * * * * * <EventTrigger.Actions>
* * * * * * * * * * * * <BeginStoryboard>
* * * * * * * * * * * * * * <Storyboard TargetProperty="LayoutTransform.Angle">
* * * * * * * * * * * * * * * * <DoubleAnimation From="0" To="360" Duration="0:0:.5"/>
* * * * * * * * * * * * * * </Storyboard>
* * * * * * * * * * * * </BeginStoryboard>
* * * * * * * * * * </EventTrigger.Actions>
* * * * * * * * </EventTrigger>
* * * * * * </Button.Triggers>
* * * * </Button>
* * * * </Grid>
</Page>

I have to wonder sometimes, why people are still using Windows forms at all :)
Actually, I know why - but, WPF is so much nicer.

--
Tom Shelton- Hide quoted text -

- Show quoted text -
Yeah, but my concern is that WPF *may* and probably require a greater
processor and graphic card than a simple Winform.

Thanks,

Onur Güzel
Jun 27 '08 #13
On 2008-06-17, kimiraikkonen <ki*************@gmail.comwrote:
On Jun 17, 7:40*pm, Tom Shelton <tom_shel...@comcastXXXXXXX.net>
wrote:
>On 2008-06-17, kimiraikkonen <kimiraikkone...@gmail.comwrote:


On Jun 17, 6:32 pm, Tom Shelton <tom_shel...@comcastXXXXXXX.net>
wrote:
On 2008-06-17, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Jun 17, 6:12 pm, Tom Shelton <tom_shel...@comcastXXXXXXX.net>
wrote:
On 2008-06-17, vino <alex_v...@discussions.microsoft.comwrote:
Ok.
If i understand, unfortunately i have to work with WPF.
I have ever tryied it but it seems to be difficult to learn how to
manipulate objects.
If you are a few complete samples of WPF i am interested in.
Thanks.
Gilles
"Herfried K. Wagner [MVP]" wrote:
>Windows Forms controls unfortunately cannot be rotated. *However, you can
rotate WPF-based controls.
>--
*M S * Herfried K. Wagner
M V P *<URL:http://dotnet.mvps.org/>
*V B * <URL:http://dotnet.mvps.org/dotnet/faqs/>
>Here is rotating a button 90 degrees in WPF...
><Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="Hi This is a button">
* * * * <Button.LayoutTransform>
* * * * * * * * <RotateTransform Angle="90" />
* * * * </Button.LayoutTransform>
</Button>
>Copy this into a tool like XamlPad and you will have a button centered and
rotated 90 degrees...
>--
Tom Shelton
I got a primitive idea, if you need to rotate a button just for 90
degrees, replace height and width. For example a newly placed button
is sized about 75;23. Then you can do:
Button1.Size = New Size(23, 75)
..and now it seems like it's rotated by 90 degrees. :)
Thanks,
Onur Güzel
>Except that the content is not rotated...
>--
Tom Shelton
Yes, you need to wrap the text of button though it's wrapped
automatically but i found out that "t" seems double as next in a 23;75
sized button with default Sans-Serif Font(8 pt).
Thanks,
Onur Güzel

The wpf version actually rotates the text as well - not just wraps it into a
column. *Here is a complete example that spins a button 360 degrees over a
half a second when it is clicked - and it uses NO procedural code....

<Page
* * * * xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
* * * * xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
* * * * <Grid>
* * * * <Button HorizontalAlignment="Center"
* * * * * * * * VerticalAlignment="Center"
* * * * * * * * Content="Hi This is a button"
* * * * * * * * RenderTransformOrigin=".5,.5">
* * * * * * <Button.LayoutTransform>
* * * * * * * * <RotateTransform Angle="0" />
* * * * * * </Button.LayoutTransform>
* * * * * * <Button.Triggers>
* * * * * * * * <EventTrigger RoutedEvent="Button.Click">
* * * * * * * * * * <EventTrigger.Actions>
* * * * * * * * * * * * <BeginStoryboard>
* * * * * * * * * * * * * * <Storyboard TargetProperty="LayoutTransform.Angle">
* * * * * * * * * * * * * * * * <DoubleAnimation From="0" To="360" Duration="0:0:.5"/>
* * * * * * * * * * * * * * </Storyboard>
* * * * * * * * * * * * </BeginStoryboard>
* * * * * * * * * * </EventTrigger.Actions>
* * * * * * * * </EventTrigger>
* * * * * * </Button.Triggers>
* * * * </Button>
* * * * </Grid>
</Page>

I have to wonder sometimes, why people are still using Windows forms at all :)
Actually, I know why - but, WPF is so much nicer.

--
Tom Shelton- Hide quoted text -

- Show quoted text -

Yeah, but my concern is that WPF *may* and probably require a greater
processor and graphic card than a simple Winform.
Well, WPF does fine on this box, and it's an old AMD Athlon XP 2000+ with 1GB of
ram. The video card is an ancient 128MB NVidia Ti4200.

--
Tom Shelton
Jun 27 '08 #14

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...
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
2
by: Ronald S. Cook | last post by:
Hi, Is there a control (either built-in or 3rd party) that I can put on my web page that I can set up to "rotate" through, let's say, images of employees at our company... say 5 seconds each. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.