• 0

how do u rotate objects in vb.net


Question

8 answers to this question

Recommended Posts

  • 0

If you mean rotated in the sense of tilting it on an angle, i don't believe that's possible, and it's not called an Object, not correct to call it that, i mean it essentially sort of is... but it's called a Control. You can position the controls in different locations, but rotating it in an angle would be hard, it depends what you want to do , have text drawn on a slanted angle? You might want to do some custom drawing.

  • 0

Well, you have to 2 options if you are going to rotate text ONLY:

A: you can use this code to make a text rotated ("TEXT ROTATED")

 ? ?Static AngDegree As Long 

 ? ?' Draw the text with angle EX: (45, 45).
 ? ? Dim graphics_path As New GraphicsPath(Drawing.Drawing2D.FillMode.Winding)
 ? ?graphics_path.AddString("TEXT ROTATED", New FontFamily("Tahoma"), ?FontStyle.Bold, 20, New Point(45, 45), StringFormat.GenericDefault)

 ? ?' rotating (45, 45).
 ? ?Dim rotation_matrix As New Matrix()
 ? ?AngDegree += 20
 ? ?rotation_matrix.RotateAt(angle, New PointF(45, 45))

 ? ?' Transforming.
 ? ?graphics_path.Transform(rotation_matrix)

 ? ?' Final View after rotating
 ? CreateGraphics.Clear(Me.BackColor)
 ? CreateGraphics.FillPath(Brushes.Black, graphics_path)
 ? ?End With

B: Build your control by using "USER CONTROL" and attaching to it the "label object" and by doing some fucntion and property for rotation.

upgrade you control properties by replacing font,size, angles and fill mode with variables which is controlled "control properties"

Note : Most of fonts works with this mode "FillMode.Winding"

Option B is cool but if you tried to move the text by using a timer, it will be flickering or may not see the text at all.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.